-
Notifications
You must be signed in to change notification settings - Fork 303
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
How should clonable
work in cloneNode(false)
?
#1249
Comments
This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); See this discussion for more context: whatwg/dom#1249 Fixed: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d
cc @avandolder |
We should probably follow the expectation when cloning UA-provided elements with shadow roots, which would be the option 1; deep cloning the shadow root. (If I'm not misunderstanding how they work, cc @emilio) |
They do not get cloned in Gecko (except for printing as a special case). A new shadow root is attached when the clone gets inserted into the document. |
Cloning the shadow tree completely makes sense to me. It does make me wonder if we at some point need to provide more cloning options. cc @rniwa |
Sounds like 3 votes (including myself) for deep-cloning the shadow tree, and one for not cloning it. @emilio would you be ok changing to a deep clone behavior? |
This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); See this discussion for more context: whatwg/dom#1249 Fixed: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d
Yeah, I don't mind either way, I'm just saying that that's not the built-in shadow tree behavior at least in Gecko. Might be worth checking with @justinfagnani about the ergonomics of this for authors too. E.g., code that does: connectedCallback() {
this.attachShadow({ ... });
} Or so will throw after cloning if we clone the shadow tree. Maybe fine? You kinda need to deal with that for moves inside the document. So over-all I think given ^ I'm fine with cloning the shadow tree. But hopefully I'm not missing something. |
Does anyone know what Blink and WebKit do? |
Blink does not clone the shadow root at all for
This is a good point. I'm really starting to think general But it sounds like we have rough consensus that modulo the other
|
This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); The behavior is for the shadow root to be deep-cloned, even though the `deep` argument to `cloneNode()` is `false`. See this discussion for more context: whatwg/dom#1249 and this summary of the consensus: whatwg/dom#1249 (comment) Fixed: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d
Yes, you would never write code like that because moves are very common. You either call
I actually don't see how cloning the shadow tree is that useful at all in the general case. It's so common that the shadow root depends on non-clonable state, that the only components this would work for would have to be completely static. |
This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); The behavior is for the shadow root to be deep-cloned, even though the `deep` argument to `cloneNode()` is `false`. See this discussion for more context: whatwg/dom#1249 and this summary of the consensus: whatwg/dom#1249 (comment) Bug: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d
This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); The behavior is for the shadow root to be deep-cloned, even though the `deep` argument to `cloneNode()` is `false`. See this discussion for more context: whatwg/dom#1249 and this summary of the consensus: whatwg/dom#1249 (comment) Bug: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5242239 Reviewed-by: David Baron <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1254312}
This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); The behavior is for the shadow root to be deep-cloned, even though the `deep` argument to `cloneNode()` is `false`. See this discussion for more context: whatwg/dom#1249 and this summary of the consensus: whatwg/dom#1249 (comment) Bug: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5242239 Reviewed-by: David Baron <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1254312}
This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); The behavior is for the shadow root to be deep-cloned, even though the `deep` argument to `cloneNode()` is `false`. See this discussion for more context: whatwg/dom#1249 and this summary of the consensus: whatwg/dom#1249 (comment) Bug: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5242239 Reviewed-by: David Baron <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1254312}
… true, a=testonly Automatic update from web-platform-tests Make shallow clone work when clonable is true This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); The behavior is for the shadow root to be deep-cloned, even though the `deep` argument to `cloneNode()` is `false`. See this discussion for more context: whatwg/dom#1249 and this summary of the consensus: whatwg/dom#1249 (comment) Bug: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5242239 Reviewed-by: David Baron <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1254312} -- wpt-commits: bf7b1d88809248c70531b45d7c202a1fc7993d2d wpt-pr: 44247
… true, a=testonly Automatic update from web-platform-tests Make shallow clone work when clonable is true This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); The behavior is for the shadow root to be deep-cloned, even though the `deep` argument to `cloneNode()` is `false`. See this discussion for more context: whatwg/dom#1249 and this summary of the consensus: whatwg/dom#1249 (comment) Bug: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5242239 Reviewed-by: David Baron <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1254312} -- wpt-commits: bf7b1d88809248c70531b45d7c202a1fc7993d2d wpt-pr: 44247
… true, a=testonly Automatic update from web-platform-tests Make shallow clone work when clonable is true This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); The behavior is for the shadow root to be deep-cloned, even though the `deep` argument to `cloneNode()` is `false`. See this discussion for more context: whatwg/dom#1249 and this summary of the consensus: whatwg/dom#1249 (comment) Bug: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5242239 Reviewed-by: David Baron <dbaronchromium.org> Auto-Submit: Mason Freed <masonfchromium.org> Commit-Queue: Mason Freed <masonfchromium.org> Cr-Commit-Position: refs/heads/main{#1254312} -- wpt-commits: bf7b1d88809248c70531b45d7c202a1fc7993d2d wpt-pr: 44247 UltraBlame original commit: ad7d9de7a73983abcd2ba32c270f068283e5104c
… true, a=testonly Automatic update from web-platform-tests Make shallow clone work when clonable is true This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); The behavior is for the shadow root to be deep-cloned, even though the `deep` argument to `cloneNode()` is `false`. See this discussion for more context: whatwg/dom#1249 and this summary of the consensus: whatwg/dom#1249 (comment) Bug: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5242239 Reviewed-by: David Baron <dbaronchromium.org> Auto-Submit: Mason Freed <masonfchromium.org> Commit-Queue: Mason Freed <masonfchromium.org> Cr-Commit-Position: refs/heads/main{#1254312} -- wpt-commits: bf7b1d88809248c70531b45d7c202a1fc7993d2d wpt-pr: 44247 UltraBlame original commit: ad7d9de7a73983abcd2ba32c270f068283e5104c
… true, a=testonly Automatic update from web-platform-tests Make shallow clone work when clonable is true This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); The behavior is for the shadow root to be deep-cloned, even though the `deep` argument to `cloneNode()` is `false`. See this discussion for more context: whatwg/dom#1249 and this summary of the consensus: whatwg/dom#1249 (comment) Bug: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5242239 Reviewed-by: David Baron <dbaronchromium.org> Auto-Submit: Mason Freed <masonfchromium.org> Commit-Queue: Mason Freed <masonfchromium.org> Cr-Commit-Position: refs/heads/main{#1254312} -- wpt-commits: bf7b1d88809248c70531b45d7c202a1fc7993d2d wpt-pr: 44247 UltraBlame original commit: ad7d9de7a73983abcd2ba32c270f068283e5104c
I guess the main issue here is that we need better test coverage for this scenario? |
This did not previously work correctly, but now, this will work: const shadow = host.attachShadow({mode:'open', clonable:true}); host.cloneNode(false); The behavior is for the shadow root to be deep-cloned, even though the `deep` argument to `cloneNode()` is `false`. See this discussion for more context: whatwg/dom#1249 and this summary of the consensus: whatwg/dom#1249 (comment) Bug: 1510466 Change-Id: I8a9de78044785675cd6bbac93d9b26286445ac8d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5242239 Reviewed-by: David Baron <[email protected]> Auto-Submit: Mason Freed <[email protected]> Commit-Queue: Mason Freed <[email protected]> Cr-Commit-Position: refs/heads/main@{#1254312}
It seems this was tested, but also required a change to the specification and that was not proposed. I created #1272 for that. |
This issue was raised as part of the Chromium review of the implementation of
clonable
. The question is what should happen here:What should happen to the shadow root? Since it is clonable, I'd expect
clone
to have a shadow root, with parameters that matchshadow
. But should the content of that shadow root be deep-cloned fromhost
? Or shouldclone.shadowRoot
be empty? Both of those feel slightly odd. I think I slightly prefer deep-cloning the shadow content, but I'm not sure.@dbaron @annevk @saschanaz
The text was updated successfully, but these errors were encountered: