ShadowRoot返回为Null-ShadowRoot显示为打开

时间:2018-09-20 03:11:51

标签: javascript html

我试图在Javascript中选择Shadow根,以便可以设置内部元素的样式。但是当使用elem.shadowRoot时,尽管ShadowRoot是下一个元素,但它返回Null。下面我粘贴了我的调试信息和结果图片

这是我第一次使用shadowRoot,因此可能会丢失一些明显的东西。

20-Sep-2018 10:55:36.494 WARNING [http-nio-8075-exec-2] org.apache.tomcat.util.http.parser.HttpParser.<clinit> Character [[] is not allowed and will continue to be rejected.
20-Sep-2018 10:55:36.494 WARNING [http-nio-8075-exec-2] org.apache.tomcat.util.http.parser.HttpParser.<clinit> Character []] is not allowed and will continue to be rejected.
20-Sep-2018 10:56:07.083 INFO [http-nio-8075-exec-10] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header
 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
 java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
    at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:479)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:684)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)

Results of Debugging

1 个答案:

答案 0 :(得分:1)

代码示例的目标是target.shadowroot,而不是shadowroot元素本身。

也请检查文档以使用firstChild方法。定位可能不正确。