Skip to content

Commit 69cb881

Browse files
committed
Bug 1876932 [wpt PR 44247] - Make shallow clone work when clonable is 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
1 parent 52d0a7d commit 69cb881

File tree

1 file changed

+168
-11
lines changed

1 file changed

+168
-11
lines changed

testing/web-platform/tests/shadow-dom/shadow-root-clonable.html

+168-11
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,37 @@
7979
'
8080
>
8181
<
82+
link
83+
rel
84+
=
85+
'
86+
help
87+
'
88+
href
89+
=
90+
'
91+
https
92+
:
93+
/
94+
/
95+
github
96+
.
97+
com
98+
/
99+
whatwg
100+
/
101+
dom
102+
/
103+
issues
104+
/
105+
1249
106+
#
107+
issuecomment
108+
-
109+
1917772229
110+
'
111+
>
112+
<
82113
script
83114
src
84115
=
@@ -158,17 +189,27 @@
158189
;
159190
root
160191
.
161-
appendChild
162-
(
163-
document
164-
.
165-
createElement
166-
(
167-
"
192+
innerHTML
193+
=
194+
'
195+
<
168196
input
169-
"
170-
)
171-
)
197+
>
198+
<
199+
div
200+
>
201+
<
202+
span
203+
>
204+
<
205+
/
206+
span
207+
>
208+
<
209+
/
210+
div
211+
>
212+
'
172213
;
173214
assert_true
174215
(
@@ -220,7 +261,7 @@
220261
children
221262
.
222263
length
223-
1
264+
2
224265
"
225266
children
226267
count
@@ -246,6 +287,122 @@
246287
"
247288
)
248289
;
290+
assert_equals
291+
(
292+
clonedRoot
293+
.
294+
children
295+
[
296+
1
297+
]
298+
.
299+
firstElementChild
300+
.
301+
localName
302+
"
303+
span
304+
"
305+
"
306+
grandchildren
307+
content
308+
"
309+
)
310+
;
311+
const
312+
shallowClone
313+
=
314+
div
315+
.
316+
cloneNode
317+
(
318+
false
319+
)
320+
;
321+
const
322+
shallowClonedRoot
323+
=
324+
shallowClone
325+
.
326+
shadowRoot
327+
;
328+
assert_true
329+
(
330+
shallowClonedRoot
331+
.
332+
clonable
333+
"
334+
clone
335+
gets
336+
the
337+
same
338+
clonable
339+
state
340+
"
341+
)
342+
;
343+
assert_equals
344+
(
345+
shallowClonedRoot
346+
.
347+
children
348+
.
349+
length
350+
2
351+
"
352+
shallow
353+
clone
354+
still
355+
deep
356+
-
357+
clones
358+
the
359+
shadow
360+
root
361+
"
362+
)
363+
;
364+
assert_equals
365+
(
366+
shallowClonedRoot
367+
.
368+
children
369+
[
370+
0
371+
]
372+
.
373+
localName
374+
"
375+
input
376+
"
377+
"
378+
shadow
379+
children
380+
content
381+
"
382+
)
383+
;
384+
assert_equals
385+
(
386+
shallowClonedRoot
387+
.
388+
children
389+
[
390+
1
391+
]
392+
.
393+
firstElementChild
394+
.
395+
localName
396+
"
397+
span
398+
"
399+
"
400+
shadow
401+
grandchildren
402+
content
403+
"
404+
)
405+
;
249406
}
250407
"
251408
attachShadow

0 commit comments

Comments
 (0)