DEV Community

Discussion on: Create Reusable Web Components in HTML

 
bennypowers profile image
Benny Powers 🇮🇱🇨🇦

a shadow, to which I guarantee you Google doesn't have access.

I wouldn't take that guarantee. Google search absolutely, 100%, without a doubt DOES read content in shadow DOM. Bing as well.

I have other doubt it would not have been better to put the template in a method of the Header class

If you're using a <template> element, then the template should either be in module scope or a static member of the class. If you make it an instance field or method, you will lose the performance benefit of only parsing the HTML once.

And this is in fact how FASTElement does it. LitElement however lets you define a render method on the instance, which will perhaps be more suitable for you.