Pregunta

Probably simple question, that I haven't really found an answer for:

Does ShadowDOM or WebComponents (as the bigger Standard) actually encapsulate JavaScript aswell? Like having seperate namespaces for each component?

From what I encountered with Polymer that wasn't the case yet, which is obvious, given that polymer is doing it's polyfilling through JS.

Thanks!

¿Fue útil?

Solución

The Shadow DOM and Custom Element specs say nothing about script encapsulation. The only thing that SD gives you is <style> encapsulation and event retargeting (events look like they come from the host element and not internal elements. For custom elements, you can do tricks to namespace your JS (e.g. anonymous self calling functions, wrapping the constructor in a namespace, etc.)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top