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

Remove quadratic behavior from clone a node #1334

Merged
merged 5 commits into from
Dec 17, 2024
Merged

Conversation

annevk
Copy link
Member

@annevk annevk commented Dec 12, 2024

Strictly speaking this should be an editorial change, but as it's fairly significant not marking it as such. This improves integration with HTML as well.

All the arguments are exported as HTML needs them as well. And they are named parameters now for clarity.

Corresponding HTML PR: whatwg/html#10859.

Fixes #1219. Closes #1220.


Preview | Diff

annevk added a commit to whatwg/html that referenced this pull request Dec 12, 2024
@annevk annevk requested review from dbaron and smaug---- December 12, 2024 17:36
dom.bs Outdated Show resolved Hide resolved
dom.bs Outdated
<li><p>For each <var>child</var> of <var>node</var>'s <a for=Element>shadow root</a>'s
<a for=tree>children</a>, in <a>tree order</a>: <a>clone a node and append</a> given
<var>child</var>, <var>copy</var>'s <a for=Element>shadow root</a>, <var>document</var>, and
<var>subtree</var>.
Copy link
Collaborator

@smaug---- smaug---- Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Gecko shadow root attaching happens after going through children.
And the same seems to happen in Chrome too https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/dom/element.cc;l=689;drc=fe99dee25a6b65dbe6c9e97099334e9c027a24a1;bpv=0;bpt=1

https://mozilla.pettay.fi/moztests/shadowclone.html
The order of slotchange events is the same in Firefox and Chrome (h6, div, span), Safari has - I was told - div, span, h6.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it is, but is that the result of cloning order or something else? As per the discussion in #695 there's already a difference between engines.

I can restore the original order here though. That seems better for now either way.

annevk added a commit that referenced this pull request Dec 16, 2024
annevk added a commit that referenced this pull request Dec 16, 2024
Strictly speaking this should be an editorial change, but as it's fairly significant not marking it as such. This improves integration with HTML as well.

As part of this change we move the shadow tree behavior under creating the element clone as that is a more logical fit.

Unfortunately subtree has to be passed everywhere as HTML needs it for its template element logic. That's also why clone a node's children is exported.

Corresponding HTML PR: SOON.

Fixes #1219. Closes #1220.
@annevk annevk force-pushed the annevk/clone-a-node branch from c88a25d to da4e899 Compare December 16, 2024 10:42
@annevk
Copy link
Member Author

annevk commented Dec 16, 2024

I've cleaned it up a bit more. Now only "clone a single node" is a separate algorithm. "Clone a single node" is not exported so other specifications cannot make use of it. @smaug---- I'd appreciate another review. I hope it's all good now. I'll align the HTML PR with this as well.

@annevk annevk requested a review from smaug---- December 16, 2024 10:53
Copy link
Member

@dbaron dbaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay getting to this. This looks good to me except for a single sentence (see below).

dom.bs Outdated Show resolved Hide resolved

<li><p>Run any <a>cloning steps</a> defined for <var>node</var> in
<a>other applicable specifications</a> and pass <var>node</var>, <var>copy</var>, and
<var>subtree</var> as parameters.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@smaug---- smaug---- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think cloning steps should be before append

@annevk annevk merged commit 7cd51e7 into main Dec 17, 2024
2 checks passed
@annevk annevk deleted the annevk/clone-a-node branch December 17, 2024 07:47
annevk added a commit to whatwg/html that referenced this pull request Dec 17, 2024
AtkinsSJ added a commit to AtkinsSJ/ladybird that referenced this pull request Jan 3, 2025
Main difference is that a chunk of the "clone a node" steps are pulled
out into a "clone a single node" algorithm.

Reflects these spec PRs:
whatwg/dom#1332
whatwg/dom#1334

Though this code is quite old so there may also be older spec changes
included here.
tcl3 pushed a commit to LadybirdBrowser/ladybird that referenced this pull request Jan 4, 2025
Main difference is that a chunk of the "clone a node" steps are pulled
out into a "clone a single node" algorithm.

Reflects these spec PRs:
whatwg/dom#1332
whatwg/dom#1334

Though this code is quite old so there may also be older spec changes
included here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants