1

I have a custom element A as "main" element and a custom element b that I have included in A. Now I added the template code in custom element b to itself by calling

  // var currentOwner = document.currentScript.ownerDocument; // doesn't work
  const tmp = currentOwner.querySelector('#b4-toggle-button');
  this.appendChild(tmpl.content.cloneNode(true));

I'm consfused why i have to determine my currentOwner variable outside the class to get the proper reference of ownerDocument while within the class i will get the reference of custom element A...

Can someone explain me this case please?

Here is the working example: https://plnkr.co/edit/fGOwdGqBXFRZCbYIUBCZ

FalloutBoy
  • 964
  • 1
  • 9
  • 22

0 Answers0