문제

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!

도움이 되었습니까?

해결책

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.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top