Nested element (web component) can’t get its template

document.currentScript contains a reference to the script that is currently parsed and executed. Therefore it is not valid anymore for your purpose when the constructor() function is called (from another script). Instead you shoud save its value in a variable at the beginning of the script, and use this variable in the constructor: <script> var … Read more