Re: [whatwg/dom] Declarative Shadow DOM (#831)

> @rniwa, you are correct that a MutationObserver could be used to grab references to the contents of the `<template shadowroot>` before the closing tag is encountered, and therefore before the shadow root is attached. That would break encapsulation if the eventual shadowroot is closed.

This breaks encapsulation regardless of whether it's open or closed. This is one of those accidental leakage. Any code that's crawling across the DOM tree can bump into this.

> This is independent of whether the element is being created or upgraded, I think. Perhaps we could just disallow the `.content` accessor on the `<template>` element if it is a _closed_ declarative shadow root?

Right, this leakage is problematic in either case, and I agree disallowing `content` access is probably the most straight-forward fix here although it discloses the information that there is a declarative shadow tree in that case too.

> On the sync parsing question for non-upgrading custom elements, I'm not sure how big of an issue this is in practice. For the SSR use case, none of the custom elements would be likely defined prior to the declarative content, so all custom elements would be upgraded later, after scripts are loaded.

I'm not sure about that. If custom element definitions are loaded as async scripts and the scripts are locally cached, they could be loaded & executed before the entire document finishes parsing.


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/831#issuecomment-606326715

Received on Tuesday, 31 March 2020 00:38:40 UTC