Skip to content
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

Closed
mfreed7 opened this issue Feb 8, 2023 · 27 comments
Closed

Add getInnerHTML() that optionally serializes declarative Shadow DOM #8867

mfreed7 opened this issue Feb 8, 2023 · 27 comments
Labels
addition/proposal New features or enhancements topic: parser topic: shadow Relates to shadow trees (as defined in DOM)

Comments

@mfreed7
Copy link
Collaborator

mfreed7 commented Feb 8, 2023

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 on Document and/or ShadowRoot 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:

const html = element.getInnerHTML({includeShadowRoots: true});
// html contains `<template shadowrootmode=...>` for any contained "open" 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:

const html = element.getInnerHTML({
  includeShadowRoots: true,
  closedRoots: [shadowRoot1, shadowRoot2, ...]
});

Thoughts? Concerns?

@zcorpan zcorpan added addition/proposal New features or enhancements topic: shadow Relates to shadow trees (as defined in DOM) topic: parser labels Feb 13, 2023
@hsivonen
Copy link
Member

innerHTML is unfortunate in that it changes behavior depending on the HTML vs. XML bit of the owning document. Having this API that says "HTML" always serialize as HTML (and the "set" counterpart parse as HTML), then having XML counterparts, and having these on all nodes regardless of the HTML vs. XML bit of the owning document would probably be a less problematic design than the old innerHTML behavior that varies with the HTML vs. XML bit of the owner doc, since a given method would always do the same thing regardless of owner-document-level state.

@hsivonen
Copy link
Member

Oops, the previous comment went to the wrong issue. For this issue, being able to serialize what can be parsed makes sense for symmetry.

@mfreed7
Copy link
Collaborator Author

mfreed7 commented Feb 27, 2023

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?

@mfreed7
Copy link
Collaborator Author

mfreed7 commented Oct 31, 2023

Now that the DSD patches have all landed, can we come back to this one? Any objections to adding:

const html = element.getInnerHTML({
  includeShadowRoots: true,
  closedRoots: [shadowRoot1, shadowRoot2, ...]
});

?

@annevk
Copy link
Member

annevk commented Oct 31, 2023

So the new parser entry points are called setHTMLUnsafe() and setHTML(). For symmetry I'd expect this to be called getHTML(), assuming we don't need the safe/unsafe distinction.

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.

@mfreed7
Copy link
Collaborator Author

mfreed7 commented Oct 31, 2023

So the new parser entry points are called setHTMLUnsafe() and setHTML(). For symmetry I'd expect this to be called getHTML(), assuming we don't need the safe/unsafe distinction.

Yep, makes sense to me. I don't believe (?) there's any need for an "unsafe" version, at least that I can see.

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.

The problem is that providing a list of the contained roots is fairly cumbersome. You have to walk the entire tree, before getHTML then walks it again. I can see this performance penalty alone, let alone the ergonomics, being a developer complaint. How about:

const html = element.getHTML({
  includeShadowRoots: true,
});

which just serializes them all? That certainly treats them equally.

@mfreed7
Copy link
Collaborator Author

mfreed7 commented Oct 31, 2023

I thought that many years ago we reached agreement that what you need for closed shadow roots we'd also use for open.

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

aarongable pushed a commit to chromium/chromium that referenced this issue Nov 7, 2023
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 <jarhar@chromium.org>
Auto-Submit: Mason Freed <masonf@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1220929}
@hsivonen
Copy link
Member

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?

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.

@hsivonen
Copy link
Member

The shape looks OK.

I should clarify, that I meant the shape on the level of 1) new (relative to innerHTML) HTML serialization getter, 2) it being about the HTML serialization (potential XML serialization as a distinct method), and 3) tunables within the HTML serialization as an option bag.

I didn't review the specifics of the tunable options.

@mfreed7
Copy link
Collaborator Author

mfreed7 commented Nov 13, 2023

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.

Thanks! I agree with your points about XML. Where do you think we should write this down, just as a Note in the spec?

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.

@mfreed7
Copy link
Collaborator Author

mfreed7 commented Nov 30, 2023

So we discussed this at the #9937 meeting, and came to rough consensus on a model like this:

  1. add an option to attachShadow() and <template shadowrootmode> to allow the shadow root to say "I opt in to serialization of this shadow root without providing a reference to me".
  2. provide a boolean option to getHTML() that says "please serialize opted-in shadow roots". The default for this option is false.
  3. provide an option to getHTML() containing a sequence of shadowRoots that should be serialized, independent of whether they opted in via the flag above.

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?

@past past removed the agenda+ To be discussed at a triage meeting label Nov 30, 2023
@annevk
Copy link
Member

annevk commented Nov 30, 2023

I think includeShadowRoots (which defaults to true if you supply shadowRoots and throws if you set it to false while also supplying shadowRoots) makes more sense than includeSerializable.

We probably want to have ShadowRoot.prototype.serializable as well for introspection (similar to the clonable suggestion).

@mfreed7
Copy link
Collaborator Author

mfreed7 commented Nov 30, 2023

I think includeShadowRoots (which defaults to true if you supply shadowRoots and throws if you set it to false while also supplying shadowRoots) makes more sense than includeSerializable.

Yep - good suggestions, both.

We probably want to have ShadowRoot.prototype.serializable as well for introspection (similar to the clonable suggestion).

I agree.

@mfreed7
Copy link
Collaborator Author

mfreed7 commented Dec 14, 2023

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.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 20, 2024
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
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Jan 20, 2024
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
@mfreed7
Copy link
Collaborator Author

mfreed7 commented Jan 25, 2024

I see, your assumption is that when you specify particular shadow roots (with shadowRoots), you're not necessarily also interested in serializable shadow roots (includeShadowRoots)? I feel ambivalent to that reframing, but I think we should rename includeShadowRoots to serializableShadowRoots if we go that way.

I'm kind of ambivalent also. It just feels a little odd that getHTML() returns none, and getHTML({shadowRoots: list}) returns list plus others. Sounds like you're ok with my proposed behavior, as long as there's a rename? @smaug---- any thoughts?

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jan 29, 2024
…accordingly [2/2], a=testonly

Automatic update from web-platform-tests
Add getHTML() and modify getInnerHTML() accordingly [2/2]

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 <masonf@chromium.org>
Reviewed-by: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1251541}

--

wpt-commits: 632cbee7f0a71696290582679f8a641e45ac6019
wpt-pr: 44107
ErichDonGubler pushed a commit to ErichDonGubler/firefox that referenced this issue Jan 30, 2024
…accordingly [2/2], a=testonly

Automatic update from web-platform-tests
Add getHTML() and modify getInnerHTML() accordingly [2/2]

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 <masonf@chromium.org>
Reviewed-by: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1251541}

--

wpt-commits: 632cbee7f0a71696290582679f8a641e45ac6019
wpt-pr: 44107
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Feb 1, 2024
…accordingly [2/2], a=testonly

Automatic update from web-platform-tests
Add getHTML() and modify getInnerHTML() accordingly [2/2]

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 <masonfchromium.org>
Reviewed-by: David Baron <dbaronchromium.org>
Cr-Commit-Position: refs/heads/main{#1251541}

--

wpt-commits: 632cbee7f0a71696290582679f8a641e45ac6019
wpt-pr: 44107

UltraBlame original commit: bed358ab233d9790ba3da77e98ed947125176de0
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Feb 1, 2024
…accordingly [2/2], a=testonly

Automatic update from web-platform-tests
Add getHTML() and modify getInnerHTML() accordingly [2/2]

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 <masonfchromium.org>
Reviewed-by: David Baron <dbaronchromium.org>
Cr-Commit-Position: refs/heads/main{#1251541}

--

wpt-commits: 632cbee7f0a71696290582679f8a641e45ac6019
wpt-pr: 44107

UltraBlame original commit: bed358ab233d9790ba3da77e98ed947125176de0
@mfreed7
Copy link
Collaborator Author

mfreed7 commented Feb 16, 2024

I'm kind of ambivalent also. It just feels a little odd that getHTML() returns none, and getHTML({shadowRoots: list}) returns list plus others. Sounds like you're ok with my proposed behavior, as long as there's a rename? @smaug---- any thoughts?

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 serializableShadowRoots, it now feels weird to throw when serializableShadowRoots is false and shadowRoots is non-empty. It feels like perhaps this should be the behavior instead:

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 serializableShadowRoots member in order to just serialize specific roots. I also don't see the danger or need for an exception.

@annevk
Copy link
Member

annevk commented Feb 16, 2024

Yeah, that makes sense.

@annevk
Copy link
Member

annevk commented Feb 16, 2024

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 setHTML[Unsafe]() are good names. However, I doubt that is the plan on the serialization side?

This will need some thought. If we just want to reuse the existing serialization algorithm maybe serialize() is a reasonable name. Enforcing HTML serialization seems hard. (What if someone inserts a CDATASection, ProcessingInstruction, or non-HTML element?)

@zcorpan might have thoughts about this. Also curious to hear from @hsivonen and @smaug----.

@mfreed7
Copy link
Collaborator Author

mfreed7 commented Feb 16, 2024

I.e. without (D), it'll be quite awkward to have to remove the serializableShadowRoots member in order to just serialize specific roots. I also don't see the danger or need for an exception.
Yeah, that makes sense.

Great, thanks, I've made that change to the PR.

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 setHTML[Unsafe]() are good names. However, I doubt that is the plan on the serialization side?

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 serialize() and instead call DOMParsing's fragment serializing algorithm. I kind of liked the parallelism to setHTML[Unsafe]() here. But I don't have terribly strong opinions.

@smaug----
Copy link
Collaborator

I'd assume this work similarly to innerHTML getter in HTML documents, if there are things like ProcessingInstructions

@annevk
Copy link
Member

annevk commented Feb 19, 2024

innerHTML's getter has an "XML code path". Given that we explicitly opted to not give setHTML() such a code path, it would be strange for getHTML() to have one. And I think it would also be strange if it worked on non-HTML elements but didn't serialize things such as namespaces.

@domenic
Copy link
Member

domenic commented Feb 20, 2024

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.

@zcorpan
Copy link
Member

zcorpan commented Feb 20, 2024

@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 getHTML() shouldn't have an XML code path, like @hsivonen said. Instead we can add getXML() if fragment serialization as XML is needed.

@mfreed7
Copy link
Collaborator Author

mfreed7 commented Feb 20, 2024

innerHTML's getter has an "XML code path". Given that we explicitly opted to not give setHTML() such a code path, it would be strange for getHTML() to have one. And I think it would also be strange if it worked on non-HTML elements but didn't serialize things such as namespaces.

Right - as I mentioned, the PR points getHTML() to the HTML fragment serialization algorithm, so it'll be parallel to both setHTML() and calling innerHTML from within an HTML document.

Given the other comments, it sounds like maybe the PR is ok as-is then, modulo other issues?

marcoscaceres pushed a commit to web-platform-tests/wpt that referenced this issue Feb 23, 2024
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 <masonf@chromium.org>
Reviewed-by: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1251541}
annevk pushed a commit to whatwg/dom that referenced this issue Apr 4, 2024
@annevk annevk closed this as completed in 6c20fe5 Apr 4, 2024
@mfreed7
Copy link
Collaborator Author

mfreed7 commented Apr 4, 2024

Thanks everyone!

rubberyuzu pushed a commit to rubberyuzu/html that referenced this issue Apr 8, 2024
Corresponding DOM PR: whatwg/dom#1256.

Closes whatwg#8867.

Co-authored-by: Domenic Denicola <d@domenic.me>
rubberyuzu added a commit to rubberyuzu/html that referenced this issue Apr 8, 2024
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 <d@domenic.me>

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.
annevk added a commit that referenced this issue Apr 8, 2024
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.
rubberyuzu added a commit to rubberyuzu/html that referenced this issue Apr 8, 2024
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 <d@domenic.me>

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.
annevk added a commit that referenced this issue Apr 10, 2024
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.
rubberyuzu added a commit to rubberyuzu/html that referenced this issue May 13, 2024
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 <d@domenic.me>

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements topic: parser topic: shadow Relates to shadow trees (as defined in DOM)
Development

No branches or pull requests

7 participants