How can I access the (unamed) slot content in web components

  components, javascript, slot, web, web-component

How can I access the content of the unnamed slot(=’I need to access this text node’ in this example) inside the web component’s connectedCallback with javascript?

With javascript shadowRoot only shows it only as without any content inside. However Chrome renders it correctly as expected.


Please note that the actual class constructor is omitted in the question for brevity.

 <template id="my-option-template">


Using the template above

<my-option>I need to access this text node</s-option> 

Source: Ask Javascript Questions