-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add getInnerHTML()
that optionally serializes declarative Shadow DOM
#8867
Comments
|
Oops, the previous comment went to the wrong issue. For this issue, being able to serialize what can be parsed makes sense for symmetry. |
Thanks for the (positive) feedback! Any thoughts on the proposed shape of the API? |
Now that the DSD patches have all landed, can we come back to this one? Any objections to adding:
? |
So the new parser entry points are called As for the shape of the API, I don't like that it makes a distinction between closed and open shadow roots. I thought that many years ago we reached agreement that what you need for closed shadow roots we'd also use for open. |
Yep, makes sense to me. I don't believe (?) there's any need for an "unsafe" version, at least that I can see.
The problem is that providing a list of the contained roots is fairly cumbersome. You have to walk the entire tree, before
which just serializes them all? That certainly treats them equally. |
Incidentally, can you link me to that agreement? I see it cited often, but I don't quite understand the rationale. I'd love to read the back-story. (I was not part of the "we" in that sentence.) |
The old-style `<template shadowroot>` declarative shadow DOM is being removed in M119. The non-standard getInnerHTML() method is still being discussed in [1]. But in the meantime, whatever the API shape ends up being, it should return the new `shadowrootmode` attribute and not the old `shadowroot` attribute. This CL makes that change. [1] whatwg/html#8867 Bug: 1396384 Change-Id: If5a8fae0e2971f2282a327294878343698189c95 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5008144 Reviewed-by: Joey Arhar <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Joey Arhar <[email protected]> Cr-Commit-Position: refs/heads/main@{#1220929}
The shape looks OK. I think it would be worthwhile to write down that if a way to obtain the XML serialization was added, it should be a second method and not a flag on the option bag (for easy feature detectability and for not having something as big as selection of the serialization syntax as an option bag item). We don't need to add an XML counterpart right now absent evidence of Web developer demand, but I think we should think through and write down how we'd go about introducing an XML counterpart if demand shows up. |
I should clarify, that I meant the shape on the level of 1) new (relative to I didn't review the specifics of the tunable options. |
Thanks! I agree with your points about XML. Where do you think we should write this down, just as a Coming back to the shape, what about this (small) tweak? const html = element.getHTML({
shadowRoots: [shadowRoot1, shadowRoot2, ...]
includeAllShadowRoots: true,
}); The idea would be: el.getHTML({shadowRoots: [root1, root2, ...]}) // Only serializes into `root1`, `root2`, ... and skips other roots. Roots can be open or closed here.
el.getHTML({includeAllShadowRoots:true}) // Serializes all open shadow roots, and no closed ones (because they're closed).
el.getHTML({includeAllShadowRoots:true, shadowRoots: [root1, ...]}) // Serializes all open shadow roots plus anything in the shadowRoots array. I'm just trying to avoid the problem that this API should be usable without having to do full recursive DOM traversal first. I'm trying to incorporate the "open and closed roots should be the same" feedback, admittedly without completely understanding it. |
So we discussed this at the #9937 meeting, and came to rough consensus on a model like this:
Assuming the above is correct, I propose this set of names: element.attachShadow({serializable: true}); // (1)
// Or <template shadowrootmode serializable> // (1)
const html = element.getHTML({
includeSerializable: true, // (2)
shadowRoots: [shadowRoot1, shadowRoot2, ...] // (3)
}); Comments? Suggestions for better names? |
I think We probably want to have |
Yep - good suggestions, both.
I agree. |
Quick update to include the last set of comments: element.attachShadow({serializable: true}); // (1)
// Or <template shadowrootmode serializable> // (1)
const html = element.getHTML({
includeShadowRoots: true, // (2)
shadowRoots: [shadowRoot1, shadowRoot2, ...] // (3)
});
// Examples
element.getHTML(); // does not serialize shadow roots
element.getHTML({includeShadowRoots: true}); // returns roots whose root.serializable is true
element.getHTML({shadowRoots: roots}); // also returns roots whose root.serializable is true
element.getHTML({includeShadowRoots: false, shadowRoots: roots}); // throws an exception
element.shadowRoot.serializable; // Returns boolean If no objections, I'll put up a spec PR to add this. |
This CL adds a new getHTML() method, and modifies the existing getInnerHTML() method accordingly. The new method follows the discussion and conclusions here: whatwg/html#8867 (comment) Essentially, that is: 1. Provide a boolean option to getHTML() that says "please serialize opted-in shadow roots". The default for this option is false. 2. Provide an option to getHTML() containing a sequence of shadowRoots that should be serialized, independent of whether they opted in via the flag above. This work falls under these two chromestatus entries: https://chromestatus.com/guide/editall/5081733588582400 https://chromestatus.com/guide/editall/5102952270528512 and these two blink-dev threads: https://groups.google.com/a/chromium.org/g/blink-dev/c/PE4VwMjLVTo https://groups.google.com/a/chromium.org/g/blink-dev/c/it0X7BOimKw Bug: 1519972, 1517959 Change-Id: I5181a0702a12d550b4dab64c0c306ea2ccb25fa3
This CL adds a new getHTML() method, and modifies the existing getInnerHTML() method accordingly. The new method follows the discussion and conclusions here: whatwg/html#8867 (comment) Essentially, that is: 1. Provide a boolean option to getHTML() that says "please serialize opted-in shadow roots". The default for this option is false. 2. Provide an option to getHTML() containing a sequence of shadowRoots that should be serialized, independent of whether they opted in via the flag above. This work falls under these two chromestatus entries: https://chromestatus.com/guide/editall/5081733588582400 https://chromestatus.com/guide/editall/5102952270528512 and these two blink-dev threads: https://groups.google.com/a/chromium.org/g/blink-dev/c/PE4VwMjLVTo https://groups.google.com/a/chromium.org/g/blink-dev/c/it0X7BOimKw Bug: 1519972, 1517959 Change-Id: I5181a0702a12d550b4dab64c0c306ea2ccb25fa3
Alright, I've put up HTML and DOM spec PRs for this behavior. It's on the larger side of the spec PRs I've written, so please go easy on me. Suggestions for improvement are welcome. One thing: having written it, with the rename to element.getHTML(); // A) does not serialize *any* shadow roots
element.getHTML({serializableShadowRoots: true}); // B) serializes all roots marked as serializable
element.getHTML({shadowRoots: roots}); // C) serializes the specific `roots` provided
element.getHTML({serializableShadowRoots: false, shadowRoots: roots}); // D) same as (C) I.e. without (D), it'll be quite awkward to have to remove the |
Yeah, that makes sense. |
Thinking about this method more I have a concern. On the parsing side we get to choose what parser to use and therefore can enforce HTML. And therefore This will need some thought. If we just want to reuse the existing serialization algorithm maybe @zcorpan might have thoughts about this. Also curious to hear from @hsivonen and @smaug----. |
Great, thanks, I've made that change to the PR.
Well, in the PR I explicitly run the HTML fragment serialization algorithm, which should correctly serialize a contained foreign element, right? I suppose we could rename the method to |
I'd assume this work similarly to innerHTML getter in HTML documents, if there are things like ProcessingInstructions |
|
For what it's worth it seems totally fine to me, and in fact desirable, to have a method that specifically runs the HTML fragment serialization algorithm. There are plenty of non-serializable things possible in the DOM, no matter what serializer you're using. I don't think we should be worried about what happens if authors use old discouraged things like namespaces or processing instructions, in combination with this new method. |
@annevk https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml is exists on all elements, but switches on the HTMLness of the document, so any strangeness is not new. https://software.hixie.ch/utilities/js/live-dom-viewer/saved/12394 I agree that |
Right - as I mentioned, the PR points Given the other comments, it sounds like maybe the PR is ok as-is then, modulo other issues? |
This CL adds a new getHTML() method, and modifies the existing getInnerHTML() method accordingly. The behavior of getInnerHTML() is not changed by this CL, but the implementation is modified to allow the code to be shared. The new method follows the discussion and conclusions here: whatwg/html#8867 (comment) Essentially, that is: 1. Provide a boolean option to getHTML() that says "please serialize opted-in shadow roots". The default for this option is false. 2. Provide an option to getHTML() containing a sequence of shadowRoots that should be serialized, independent of whether they opted in via the flag above. This work falls under these two chromestatus entries: https://chromestatus.com/feature/5081733588582400 https://chromestatus.com/feature/5102952270528512 and these two blink-dev threads: https://groups.google.com/a/chromium.org/g/blink-dev/c/PE4VwMjLVTo https://groups.google.com/a/chromium.org/g/blink-dev/c/it0X7BOimKw Bug: 1519972, 1517959 Change-Id: I5181a0702a12d550b4dab64c0c306ea2ccb25fa3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5219591 Commit-Queue: Mason Freed <[email protected]> Reviewed-by: David Baron <[email protected]> Cr-Commit-Position: refs/heads/main@{#1251541}
Corresponding HTML PR & issue: whatwg/html#10139 & whatwg/html#8867.
Thanks everyone! |
Corresponding DOM PR: whatwg/dom#1256. Closes whatwg#8867. Co-authored-by: Domenic Denicola <[email protected]>
Allow top layer elements to be nested within popovers This allows top layer elements, including the dialog element, to be nested inside of an open popover, by not closing the popover when the new top layer element is opened. Without this patch, opening a modal dialog inside of a popover will make the page inert and make the dialog invisible. Fixes whatwg#9998. See also whatwg/fullscreen#237. Editorial: order of comparisons For consistency: - greater than or equal to - less than or equal to Improve element reflection This attempts to make the following improvements: 1. Make it more clear that initializing attr is not the first step in an algorithm, but rather something that counts for all the list items. 2. Rewrite the associated element(s) fields as algorithms. As there are no downstream references so far this is a change we can still make. 3. Add another layer of caching that is separate from the FrozenArray to avoid having to compare a list of elements with a FrozenArray directly. This helps with whatwg#10219. Disable PageSwapEvent's activation on cross-origin redirects Closes whatwg#10196. Upstream Long Animation Frames monkey-patches Long Animation Frames (https://w3c.github.io/long-animation-frames/) expects a few calls from HTML and other specs, for reporting when tasks, rendering or JS entry points take place. This moves those calls from the Long Animation Frames spec to HTML. Preload: only allow certain values for as="" Closes whatwg#8332. Call the view transition page visibility change steps This allows the CSS view-transitions spec to react to page visibility changes. Specifically, skip the active transition once a page is hidden. See w3c/csswg-drafts#9543. Style marquee using overflow: hidden This matches Chromium and WebKit. Tests will be worked on in https://bugzilla.mozilla.org/show_bug.cgi?id=306344. Editorial: export Element's innerText getter and setter steps These will be used by Trusted Types (and eventually HTML once upstreamed) as part of shadowing this attribute to HTMLScriptElement. Add getHTML() and serializable shadow roots Corresponding DOM PR: whatwg/dom#1256. Closes whatwg#8867. Co-authored-by: Domenic Denicola <[email protected]> Make buttons respect display: none/contents in button layout Fixes whatwg#10238. This matches what is already implemented in browsers. Remove duplicate requirement for 'overflow' for marquee The duplication was introduced by whatwg#10243. Meta: make all the SVGs darkmode-aware Also tag them as such, so that they don't get a white background after whatwg/whatwg.org#439 is merged. Warn that the XML syntax is not recommended Closes whatwg#10237.
I missed this in review but my understanding of the discussion we had around #8867 was that the contract would be the same for open and closed shadow roots.
Allow top layer elements to be nested within popovers This allows top layer elements, including the dialog element, to be nested inside of an open popover, by not closing the popover when the new top layer element is opened. Without this patch, opening a modal dialog inside of a popover will make the page inert and make the dialog invisible. Fixes whatwg#9998. See also whatwg/fullscreen#237. Editorial: order of comparisons For consistency: - greater than or equal to - less than or equal to Improve element reflection This attempts to make the following improvements: 1. Make it more clear that initializing attr is not the first step in an algorithm, but rather something that counts for all the list items. 2. Rewrite the associated element(s) fields as algorithms. As there are no downstream references so far this is a change we can still make. 3. Add another layer of caching that is separate from the FrozenArray to avoid having to compare a list of elements with a FrozenArray directly. This helps with whatwg#10219. Disable PageSwapEvent's activation on cross-origin redirects Closes whatwg#10196. Upstream Long Animation Frames monkey-patches Long Animation Frames (https://w3c.github.io/long-animation-frames/) expects a few calls from HTML and other specs, for reporting when tasks, rendering or JS entry points take place. This moves those calls from the Long Animation Frames spec to HTML. Preload: only allow certain values for as="" Closes whatwg#8332. Call the view transition page visibility change steps This allows the CSS view-transitions spec to react to page visibility changes. Specifically, skip the active transition once a page is hidden. See w3c/csswg-drafts#9543. Style marquee using overflow: hidden This matches Chromium and WebKit. Tests will be worked on in https://bugzilla.mozilla.org/show_bug.cgi?id=306344. Editorial: export Element's innerText getter and setter steps These will be used by Trusted Types (and eventually HTML once upstreamed) as part of shadowing this attribute to HTMLScriptElement. Add getHTML() and serializable shadow roots Corresponding DOM PR: whatwg/dom#1256. Closes whatwg#8867. Co-authored-by: Domenic Denicola <[email protected]> Make buttons respect display: none/contents in button layout Fixes whatwg#10238. This matches what is already implemented in browsers. Remove duplicate requirement for 'overflow' for marquee The duplication was introduced by whatwg#10243. Meta: make all the SVGs darkmode-aware Also tag them as such, so that they don't get a white background after whatwg/whatwg.org#439 is merged. Warn that the XML syntax is not recommended Closes whatwg#10237.
I missed this in review but my understanding of the discussion we had around #8867 was that the contract would be the same for open and closed shadow roots. Tests: web-platform-tests/wpt#45624.
Allow top layer elements to be nested within popovers This allows top layer elements, including the dialog element, to be nested inside of an open popover, by not closing the popover when the new top layer element is opened. Without this patch, opening a modal dialog inside of a popover will make the page inert and make the dialog invisible. Fixes whatwg#9998. See also whatwg/fullscreen#237. Editorial: order of comparisons For consistency: - greater than or equal to - less than or equal to Improve element reflection This attempts to make the following improvements: 1. Make it more clear that initializing attr is not the first step in an algorithm, but rather something that counts for all the list items. 2. Rewrite the associated element(s) fields as algorithms. As there are no downstream references so far this is a change we can still make. 3. Add another layer of caching that is separate from the FrozenArray to avoid having to compare a list of elements with a FrozenArray directly. This helps with whatwg#10219. Disable PageSwapEvent's activation on cross-origin redirects Closes whatwg#10196. Upstream Long Animation Frames monkey-patches Long Animation Frames (https://w3c.github.io/long-animation-frames/) expects a few calls from HTML and other specs, for reporting when tasks, rendering or JS entry points take place. This moves those calls from the Long Animation Frames spec to HTML. Preload: only allow certain values for as="" Closes whatwg#8332. Call the view transition page visibility change steps This allows the CSS view-transitions spec to react to page visibility changes. Specifically, skip the active transition once a page is hidden. See w3c/csswg-drafts#9543. Style marquee using overflow: hidden This matches Chromium and WebKit. Tests will be worked on in https://bugzilla.mozilla.org/show_bug.cgi?id=306344. Editorial: export Element's innerText getter and setter steps These will be used by Trusted Types (and eventually HTML once upstreamed) as part of shadowing this attribute to HTMLScriptElement. Add getHTML() and serializable shadow roots Corresponding DOM PR: whatwg/dom#1256. Closes whatwg#8867. Co-authored-by: Domenic Denicola <[email protected]> Make buttons respect display: none/contents in button layout Fixes whatwg#10238. This matches what is already implemented in browsers. Remove duplicate requirement for 'overflow' for marquee The duplication was introduced by whatwg#10243. Meta: make all the SVGs darkmode-aware Also tag them as such, so that they don't get a white background after whatwg/whatwg.org#439 is merged. Warn that the XML syntax is not recommended Closes whatwg#10237.
Allow top layer elements to be nested within popovers This allows top layer elements, including the dialog element, to be nested inside of an open popover, by not closing the popover when the new top layer element is opened. Without this patch, opening a modal dialog inside of a popover will make the page inert and make the dialog invisible. Fixes whatwg#9998. See also whatwg/fullscreen#237. Editorial: order of comparisons For consistency: - greater than or equal to - less than or equal to Improve element reflection This attempts to make the following improvements: 1. Make it more clear that initializing attr is not the first step in an algorithm, but rather something that counts for all the list items. 2. Rewrite the associated element(s) fields as algorithms. As there are no downstream references so far this is a change we can still make. 3. Add another layer of caching that is separate from the FrozenArray to avoid having to compare a list of elements with a FrozenArray directly. This helps with whatwg#10219. Disable PageSwapEvent's activation on cross-origin redirects Closes whatwg#10196. Upstream Long Animation Frames monkey-patches Long Animation Frames (https://w3c.github.io/long-animation-frames/) expects a few calls from HTML and other specs, for reporting when tasks, rendering or JS entry points take place. This moves those calls from the Long Animation Frames spec to HTML. Preload: only allow certain values for as="" Closes whatwg#8332. Call the view transition page visibility change steps This allows the CSS view-transitions spec to react to page visibility changes. Specifically, skip the active transition once a page is hidden. See w3c/csswg-drafts#9543. Style marquee using overflow: hidden This matches Chromium and WebKit. Tests will be worked on in https://bugzilla.mozilla.org/show_bug.cgi?id=306344. Editorial: export Element's innerText getter and setter steps These will be used by Trusted Types (and eventually HTML once upstreamed) as part of shadowing this attribute to HTMLScriptElement. Add getHTML() and serializable shadow roots Corresponding DOM PR: whatwg/dom#1256. Closes whatwg#8867. Co-authored-by: Domenic Denicola <[email protected]> Make buttons respect display: none/contents in button layout Fixes whatwg#10238. This matches what is already implemented in browsers. Remove duplicate requirement for 'overflow' for marquee The duplication was introduced by whatwg#10243. Meta: make all the SVGs darkmode-aware Also tag them as such, so that they don't get a white background after whatwg/whatwg.org#439 is merged. Warn that the XML syntax is not recommended Closes whatwg#10237.
Allow top layer elements to be nested within popovers This allows top layer elements, including the dialog element, to be nested inside of an open popover, by not closing the popover when the new top layer element is opened. Without this patch, opening a modal dialog inside of a popover will make the page inert and make the dialog invisible. Fixes whatwg#9998. See also whatwg/fullscreen#237. Editorial: order of comparisons For consistency: - greater than or equal to - less than or equal to Improve element reflection This attempts to make the following improvements: 1. Make it more clear that initializing attr is not the first step in an algorithm, but rather something that counts for all the list items. 2. Rewrite the associated element(s) fields as algorithms. As there are no downstream references so far this is a change we can still make. 3. Add another layer of caching that is separate from the FrozenArray to avoid having to compare a list of elements with a FrozenArray directly. This helps with whatwg#10219. Disable PageSwapEvent's activation on cross-origin redirects Closes whatwg#10196. Upstream Long Animation Frames monkey-patches Long Animation Frames (https://w3c.github.io/long-animation-frames/) expects a few calls from HTML and other specs, for reporting when tasks, rendering or JS entry points take place. This moves those calls from the Long Animation Frames spec to HTML. Preload: only allow certain values for as="" Closes whatwg#8332. Call the view transition page visibility change steps This allows the CSS view-transitions spec to react to page visibility changes. Specifically, skip the active transition once a page is hidden. See w3c/csswg-drafts#9543. Style marquee using overflow: hidden This matches Chromium and WebKit. Tests will be worked on in https://bugzilla.mozilla.org/show_bug.cgi?id=306344. Editorial: export Element's innerText getter and setter steps These will be used by Trusted Types (and eventually HTML once upstreamed) as part of shadowing this attribute to HTMLScriptElement. Add getHTML() and serializable shadow roots Corresponding DOM PR: whatwg/dom#1256. Closes whatwg#8867. Co-authored-by: Domenic Denicola <[email protected]> Make buttons respect display: none/contents in button layout Fixes whatwg#10238. This matches what is already implemented in browsers. Remove duplicate requirement for 'overflow' for marquee The duplication was introduced by whatwg#10243. Meta: make all the SVGs darkmode-aware Also tag them as such, so that they don't get a white background after whatwg/whatwg.org#439 is merged. Warn that the XML syntax is not recommended Closes whatwg#10237.
Corresponding HTML PR & issue: whatwg/html#10139 & whatwg/html#8867.
Allow top layer elements to be nested within popovers This allows top layer elements, including the dialog element, to be nested inside of an open popover, by not closing the popover when the new top layer element is opened. Without this patch, opening a modal dialog inside of a popover will make the page inert and make the dialog invisible. Fixes whatwg#9998. See also whatwg/fullscreen#237. Editorial: order of comparisons For consistency: - greater than or equal to - less than or equal to Improve element reflection This attempts to make the following improvements: 1. Make it more clear that initializing attr is not the first step in an algorithm, but rather something that counts for all the list items. 2. Rewrite the associated element(s) fields as algorithms. As there are no downstream references so far this is a change we can still make. 3. Add another layer of caching that is separate from the FrozenArray to avoid having to compare a list of elements with a FrozenArray directly. This helps with whatwg#10219. Disable PageSwapEvent's activation on cross-origin redirects Closes whatwg#10196. Upstream Long Animation Frames monkey-patches Long Animation Frames (https://w3c.github.io/long-animation-frames/) expects a few calls from HTML and other specs, for reporting when tasks, rendering or JS entry points take place. This moves those calls from the Long Animation Frames spec to HTML. Preload: only allow certain values for as="" Closes whatwg#8332. Call the view transition page visibility change steps This allows the CSS view-transitions spec to react to page visibility changes. Specifically, skip the active transition once a page is hidden. See w3c/csswg-drafts#9543. Style marquee using overflow: hidden This matches Chromium and WebKit. Tests will be worked on in https://bugzilla.mozilla.org/show_bug.cgi?id=306344. Editorial: export Element's innerText getter and setter steps These will be used by Trusted Types (and eventually HTML once upstreamed) as part of shadowing this attribute to HTMLScriptElement. Add getHTML() and serializable shadow roots Corresponding DOM PR: whatwg/dom#1256. Closes whatwg#8867. Co-authored-by: Domenic Denicola <[email protected]> Make buttons respect display: none/contents in button layout Fixes whatwg#10238. This matches what is already implemented in browsers. Remove duplicate requirement for 'overflow' for marquee The duplication was introduced by whatwg#10243. Meta: make all the SVGs darkmode-aware Also tag them as such, so that they don't get a white background after whatwg/whatwg.org#439 is merged. Warn that the XML syntax is not recommended Closes whatwg#10237.
Allow top layer elements to be nested within popovers This allows top layer elements, including the dialog element, to be nested inside of an open popover, by not closing the popover when the new top layer element is opened. Without this patch, opening a modal dialog inside of a popover will make the page inert and make the dialog invisible. Fixes whatwg#9998. See also whatwg/fullscreen#237. Editorial: order of comparisons For consistency: - greater than or equal to - less than or equal to Improve element reflection This attempts to make the following improvements: 1. Make it more clear that initializing attr is not the first step in an algorithm, but rather something that counts for all the list items. 2. Rewrite the associated element(s) fields as algorithms. As there are no downstream references so far this is a change we can still make. 3. Add another layer of caching that is separate from the FrozenArray to avoid having to compare a list of elements with a FrozenArray directly. This helps with whatwg#10219. Disable PageSwapEvent's activation on cross-origin redirects Closes whatwg#10196. Upstream Long Animation Frames monkey-patches Long Animation Frames (https://w3c.github.io/long-animation-frames/) expects a few calls from HTML and other specs, for reporting when tasks, rendering or JS entry points take place. This moves those calls from the Long Animation Frames spec to HTML. Preload: only allow certain values for as="" Closes whatwg#8332. Call the view transition page visibility change steps This allows the CSS view-transitions spec to react to page visibility changes. Specifically, skip the active transition once a page is hidden. See w3c/csswg-drafts#9543. Style marquee using overflow: hidden This matches Chromium and WebKit. Tests will be worked on in https://bugzilla.mozilla.org/show_bug.cgi?id=306344. Editorial: export Element's innerText getter and setter steps These will be used by Trusted Types (and eventually HTML once upstreamed) as part of shadowing this attribute to HTMLScriptElement. Add getHTML() and serializable shadow roots Corresponding DOM PR: whatwg/dom#1256. Closes whatwg#8867. Co-authored-by: Domenic Denicola <[email protected]> Make buttons respect display: none/contents in button layout Fixes whatwg#10238. This matches what is already implemented in browsers. Remove duplicate requirement for 'overflow' for marquee The duplication was introduced by whatwg#10243. Meta: make all the SVGs darkmode-aware Also tag them as such, so that they don't get a white background after whatwg/whatwg.org#439 is merged. Warn that the XML syntax is not recommended Closes whatwg#10237.
Allow top layer elements to be nested within popovers This allows top layer elements, including the dialog element, to be nested inside of an open popover, by not closing the popover when the new top layer element is opened. Without this patch, opening a modal dialog inside of a popover will make the page inert and make the dialog invisible. Fixes whatwg#9998. See also whatwg/fullscreen#237. Editorial: order of comparisons For consistency: - greater than or equal to - less than or equal to Improve element reflection This attempts to make the following improvements: 1. Make it more clear that initializing attr is not the first step in an algorithm, but rather something that counts for all the list items. 2. Rewrite the associated element(s) fields as algorithms. As there are no downstream references so far this is a change we can still make. 3. Add another layer of caching that is separate from the FrozenArray to avoid having to compare a list of elements with a FrozenArray directly. This helps with whatwg#10219. Disable PageSwapEvent's activation on cross-origin redirects Closes whatwg#10196. Upstream Long Animation Frames monkey-patches Long Animation Frames (https://w3c.github.io/long-animation-frames/) expects a few calls from HTML and other specs, for reporting when tasks, rendering or JS entry points take place. This moves those calls from the Long Animation Frames spec to HTML. Preload: only allow certain values for as="" Closes whatwg#8332. Call the view transition page visibility change steps This allows the CSS view-transitions spec to react to page visibility changes. Specifically, skip the active transition once a page is hidden. See w3c/csswg-drafts#9543. Style marquee using overflow: hidden This matches Chromium and WebKit. Tests will be worked on in https://bugzilla.mozilla.org/show_bug.cgi?id=306344. Editorial: export Element's innerText getter and setter steps These will be used by Trusted Types (and eventually HTML once upstreamed) as part of shadowing this attribute to HTMLScriptElement. Add getHTML() and serializable shadow roots Corresponding DOM PR: whatwg/dom#1256. Closes whatwg#8867. Co-authored-by: Domenic Denicola <[email protected]> Make buttons respect display: none/contents in button layout Fixes whatwg#10238. This matches what is already implemented in browsers. Remove duplicate requirement for 'overflow' for marquee The duplication was introduced by whatwg#10243. Meta: make all the SVGs darkmode-aware Also tag them as such, so that they don't get a white background after whatwg/whatwg.org#439 is merged. Warn that the XML syntax is not recommended Closes whatwg#10237.
This issue is split out from the discussion that starts roughly here #5465 (comment). The original Declarative Shadow DOM spec PR included this functionality, which allowed a DOM sub-tree to be serialized in a way that doesn't throw away all of the contained shadow roots. To facilitate landing that PR, this functionality was removed. I'd like to use this issue to resume that discussion.
The problem statement is that DOM content containing developer shadow roots (i.e. not UA shadow roots) cannot be serialized. Doing so today requires a manual tree walk in JS land, manually grabbing shadow roots and serializing them into
<template shadowrootmode>
elements.The ideal solution would be for
const html = element.innerHTML;
to just start serializing shadow roots like it already serializes the rest of the DOM into HTML. However, this is almost surely not web compatible. One option is to provide an attribute onDocument
and/orShadowRoot
that opts-in to this serialization behavior. However, given the recent push to define new parser entrypoints that are functions instead of attributes, it seems to make more sense to also define a new functional getter that optionally (or always?) serializes shadow roots:To preserve the encapsulation of "closed" shadow roots, another option would be needed in the case that "closed" shadow roots want to be serialized:
Thoughts? Concerns?
The text was updated successfully, but these errors were encountered: