Skip to content

Commit c078a9a

Browse files
committedFeb 16, 2024
Bug 1878205 [wpt PR 44369] - Change the behavior of clonable to be more opt-in, a=testonly
Automatic update from web-platform-tests Change the behavior of clonable to be more opt-in See the discussion here: whatwg/html#10107 (comment) The existing *shipped* behavior (i.e. before the `clonable` concept was introduced) was that any declarative shadow root *within a `<template>`* would be automatically cloned, but no others. The semi-new behavior is the `clonable` bit concept, in which all declarative shadow roots have their `clonable` bit set to true, so they automatically get cloned by `cloneNode()`. That's regardless of whether they are inside or outside a template. The new consensus is that the "semi-new" clonable behavior is likely web-incompatible, because clones will just start getting shadow roots included. Plus it wasn't very developer-desirable. The new consensus is therefore to add a `shadowrootclonable` attribute for declarative shadow dom that allows a shadow root to opt-in to this behavior, but the default for all shadow roots will be `clonable=false`. This CL implements the new consensus behind the ShadowRootClonable flag. If the flag is false, the "shipped" behavior will be emulated via setting `clonable` in an equivalent way. See these three spec PRs: whatwg/dom#1246 whatwg/html#10069 whatwg/html#10117 Bug: 1510466 Change-Id: Ice7c7579094eb08b882c4bb44f93045f23b8f222 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5260748 Reviewed-by: David Baron <dbaronchromium.org> Auto-Submit: Mason Freed <masonfchromium.org> Commit-Queue: Mason Freed <masonfchromium.org> Cr-Commit-Position: refs/heads/main{#1258910} -- wpt-commits: 33d11f1db34802fda00e64ddeb0b7ef040cf65be wpt-pr: 44369 UltraBlame original commit: 7d4902dfa32c013568c445861c332c29e4c1134f
1 parent 4449eb4 commit c078a9a

6 files changed

+455
-95
lines changed
 

‎testing/web-platform/tests/scroll-animations/css/scroll-timeline-name-shadow.html

+4
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@
315315
shadowrootmode
316316
=
317317
open
318+
shadowrootclonable
318319
>
319320
<
320321
style
@@ -525,6 +526,7 @@
525526
shadowrootmode
526527
=
527528
open
529+
shadowrootclonable
528530
>
529531
<
530532
style
@@ -748,6 +750,7 @@
748750
shadowrootmode
749751
=
750752
open
753+
shadowrootclonable
751754
>
752755
<
753756
style
@@ -1036,6 +1039,7 @@
10361039
shadowrootmode
10371040
=
10381041
open
1042+
shadowrootclonable
10391043
>
10401044
<
10411045
style

‎testing/web-platform/tests/scroll-animations/css/view-timeline-name-shadow.html

+4
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@
317317
shadowrootmode
318318
=
319319
open
320+
shadowrootclonable
320321
>
321322
<
322323
style
@@ -520,6 +521,7 @@
520521
shadowrootmode
521522
=
522523
open
524+
shadowrootclonable
523525
>
524526
<
525527
style
@@ -737,6 +739,7 @@
737739
shadowrootmode
738740
=
739741
open
742+
shadowrootclonable
740743
>
741744
<
742745
style
@@ -1013,6 +1016,7 @@
10131016
shadowrootmode
10141017
=
10151018
open
1019+
shadowrootclonable
10161020
>
10171021
<
10181022
style

‎testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-basic.html

+242-11
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,186 @@
14391439
'
14401440
)
14411441
;
1442+
test
1443+
(
1444+
(
1445+
)
1446+
=
1447+
>
1448+
{
1449+
const
1450+
div
1451+
=
1452+
document
1453+
.
1454+
createElement
1455+
(
1456+
'
1457+
div
1458+
'
1459+
)
1460+
;
1461+
div
1462+
.
1463+
setHTMLUnsafe
1464+
(
1465+
<
1466+
div
1467+
id
1468+
=
1469+
"
1470+
host
1471+
"
1472+
>
1473+
<
1474+
template
1475+
shadowrootmode
1476+
=
1477+
"
1478+
open
1479+
"
1480+
shadowrootclonable
1481+
>
1482+
<
1483+
/
1484+
template
1485+
>
1486+
<
1487+
/
1488+
div
1489+
>
1490+
)
1491+
;
1492+
var
1493+
host
1494+
=
1495+
div
1496+
.
1497+
querySelector
1498+
(
1499+
'
1500+
#
1501+
host
1502+
'
1503+
)
1504+
;
1505+
assert_true
1506+
(
1507+
!
1508+
!
1509+
host
1510+
.
1511+
shadowRoot
1512+
"
1513+
No
1514+
shadow
1515+
root
1516+
found
1517+
"
1518+
)
1519+
;
1520+
assert_true
1521+
(
1522+
host
1523+
.
1524+
shadowRoot
1525+
.
1526+
clonable
1527+
"
1528+
clonable
1529+
should
1530+
be
1531+
true
1532+
"
1533+
)
1534+
;
1535+
div
1536+
.
1537+
setHTMLUnsafe
1538+
(
1539+
<
1540+
div
1541+
id
1542+
=
1543+
"
1544+
host
1545+
"
1546+
>
1547+
<
1548+
template
1549+
shadowrootmode
1550+
=
1551+
"
1552+
open
1553+
"
1554+
>
1555+
<
1556+
/
1557+
template
1558+
>
1559+
<
1560+
/
1561+
div
1562+
>
1563+
)
1564+
;
1565+
host
1566+
=
1567+
div
1568+
.
1569+
querySelector
1570+
(
1571+
'
1572+
#
1573+
host
1574+
'
1575+
)
1576+
;
1577+
assert_true
1578+
(
1579+
!
1580+
!
1581+
host
1582+
.
1583+
shadowRoot
1584+
"
1585+
No
1586+
shadow
1587+
root
1588+
found
1589+
"
1590+
)
1591+
;
1592+
assert_false
1593+
(
1594+
host
1595+
.
1596+
shadowRoot
1597+
.
1598+
clonable
1599+
"
1600+
clonable
1601+
should
1602+
be
1603+
false
1604+
without
1605+
the
1606+
shadowrootclonable
1607+
attribute
1608+
"
1609+
)
1610+
;
1611+
}
1612+
'
1613+
Declarative
1614+
Shadow
1615+
DOM
1616+
:
1617+
clonable
1618+
attribute
1619+
'
1620+
)
1621+
;
14421622
<
14431623
/
14441624
script
@@ -1531,8 +1711,9 @@
15311711
'
15321712
)
15331713
;
1534-
assert_equals
1535-
(
1714+
const
1715+
leftover
1716+
=
15361717
host
15371718
.
15381719
querySelector
@@ -1541,15 +1722,57 @@
15411722
template
15421723
'
15431724
)
1544-
null
1545-
"
1546-
No
1725+
;
1726+
assert_true
1727+
(
1728+
!
1729+
!
15471730
leftover
1731+
"
1732+
The
1733+
second
1734+
(
1735+
duplicate
1736+
)
15481737
template
1549-
nodes
1550-
from
1551-
either
1552-
root
1738+
should
1739+
be
1740+
left
1741+
in
1742+
the
1743+
DOM
1744+
"
1745+
)
1746+
;
1747+
assert_true
1748+
(
1749+
leftover
1750+
instanceof
1751+
HTMLTemplateElement
1752+
)
1753+
;
1754+
assert_equals
1755+
(
1756+
leftover
1757+
.
1758+
getAttribute
1759+
(
1760+
'
1761+
shadowrootmode
1762+
'
1763+
)
1764+
"
1765+
closed
1766+
"
1767+
)
1768+
;
1769+
assert_equals
1770+
(
1771+
leftover
1772+
.
1773+
shadowRootMode
1774+
"
1775+
closed
15531776
"
15541777
)
15551778
;
@@ -1595,14 +1818,14 @@
15951818
textContent
15961819
'
15971820
root
1598-
2
1821+
1
15991822
'
16001823
"
16011824
Content
16021825
should
16031826
come
16041827
from
1605-
last
1828+
first
16061829
declarative
16071830
shadow
16081831
root
@@ -1649,6 +1872,7 @@
16491872
shadowrootmode
16501873
=
16511874
open
1875+
shadowrootclonable
16521876
>
16531877
Content
16541878
<
@@ -2043,6 +2267,10 @@
20432267
declarative
20442268
shadow
20452269
root
2270+
(
2271+
with
2272+
shadowrootclonable
2273+
)
20462274
'
20472275
)
20482276
;
@@ -2092,6 +2320,7 @@
20922320
shadowrootmode
20932321
=
20942322
open
2323+
shadowrootclonable
20952324
>
20962325
Content
20972326
<
@@ -2287,6 +2516,7 @@
22872516
shadowrootmode
22882517
=
22892518
open
2519+
shadowrootclonable
22902520
>
22912521
Content
22922522
<
@@ -2473,6 +2703,7 @@
24732703
shadowrootmode
24742704
=
24752705
open
2706+
shadowrootclonable
24762707
>
24772708
<
24782709
video

‎testing/web-platform/tests/shadow-dom/declarative/declarative-shadow-dom-repeats.html

+6-44
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@
503503
=
504504
open
505505
shadowrootdelegatesfocus
506+
shadowrootclonable
506507
>
507508
Open
508509
delegates
@@ -512,19 +513,18 @@
512513
the
513514
default
514515
)
515-
named
516-
slot
517-
assignment
516+
clonable
518517
(
518+
not
519519
the
520520
default
521521
)
522-
clonable
522+
named
523+
slot
524+
assignment
523525
(
524526
the
525527
default
526-
for
527-
declarative
528528
)
529529
<
530530
/
@@ -680,40 +680,6 @@
680680
'
681681
)
682682
;
683-
/
684-
/
685-
See
686-
https
687-
:
688-
/
689-
/
690-
github
691-
.
692-
com
693-
/
694-
whatwg
695-
/
696-
html
697-
/
698-
issues
699-
/
700-
10107
701-
:
702-
the
703-
behavior
704-
of
705-
the
706-
/
707-
/
708-
clonable
709-
flag
710-
is
711-
still
712-
being
713-
discussed
714-
.
715-
/
716-
/
717683
assert_throws_dom
718684
(
719685
"
@@ -724,8 +690,6 @@
724690
=
725691
>
726692
{
727-
/
728-
/
729693
open2
730694
.
731695
attachShadow
@@ -750,8 +714,6 @@
750714
}
751715
)
752716
;
753-
/
754-
/
755717
}
756718
'
757719
Mismatched

‎testing/web-platform/tests/shadow-dom/declarative/gethtml.tentative.html

+49
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
mode
132132
delegatesFocus
133133
serializable
134+
clonable
134135
)
135136
{
136137
const
@@ -295,6 +296,7 @@
295296
delegatesFocus
296297
:
297298
delegatesFocus
299+
clonable
298300
}
299301
;
300302
let
@@ -390,6 +392,21 @@
390392
'
391393
'
392394
;
395+
const
396+
clonableAttr
397+
=
398+
clonable
399+
?
400+
'
401+
shadowrootclonable
402+
=
403+
"
404+
"
405+
'
406+
:
407+
'
408+
'
409+
;
393410
if
394411
(
395412
allowsShadowDom
@@ -419,6 +436,9 @@
419436
{
420437
serializableAttr
421438
}
439+
{
440+
clonableAttr
441+
}
422442
>
423443
;
424444
wrapper
@@ -549,6 +569,9 @@
549569
{
550570
serializableAttr
551571
}
572+
{
573+
clonableAttr
574+
}
552575
>
553576
<
554577
slot
@@ -604,6 +627,14 @@
604627
expectedSerializable
605628
)
606629
;
630+
assert_equals
631+
(
632+
shadowRoot
633+
.
634+
clonable
635+
clonable
636+
)
637+
;
607638
shadowRoot
608639
.
609640
appendChild
@@ -998,6 +1029,11 @@
9981029
{
9991030
serializable
10001031
}
1032+
clonable
1033+
=
1034+
{
1035+
clonable
1036+
}
10011037
.
10021038
:
10031039
'
@@ -1101,6 +1137,17 @@
11011137
for
11021138
(
11031139
const
1140+
clonable
1141+
of
1142+
[
1143+
false
1144+
true
1145+
]
1146+
)
1147+
{
1148+
for
1149+
(
1150+
const
11041151
mode
11051152
of
11061153
[
@@ -1138,13 +1185,15 @@
11381185
mode
11391186
delegatesFocus
11401187
serializable
1188+
clonable
11411189
)
11421190
;
11431191
}
11441192
}
11451193
}
11461194
}
11471195
}
1196+
}
11481197
else
11491198
{
11501199
testElementType

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

+150-40
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,17 @@
584584
root
585585
)
586586
;
587-
assert_true
587+
assert_false
588588
(
589589
root
590590
.
591591
clonable
592592
"
593593
clonable
594594
is
595+
*
596+
not
597+
*
595598
automatically
596599
true
597600
for
@@ -623,6 +626,135 @@
623626
assert_true
624627
(
625628
!
629+
clonedRoot
630+
'
631+
no
632+
shadow
633+
root
634+
gets
635+
cloned
636+
'
637+
)
638+
;
639+
}
640+
"
641+
declarative
642+
shadow
643+
roots
644+
do
645+
*
646+
not
647+
*
648+
get
649+
clonable
650+
:
651+
true
652+
automatically
653+
"
654+
)
655+
;
656+
test
657+
(
658+
(
659+
)
660+
=
661+
>
662+
{
663+
const
664+
div
665+
=
666+
document
667+
.
668+
createElement
669+
(
670+
"
671+
div
672+
"
673+
)
674+
;
675+
div
676+
.
677+
setHTMLUnsafe
678+
(
679+
'
680+
<
681+
div
682+
>
683+
<
684+
template
685+
shadowrootmode
686+
=
687+
open
688+
shadowrootclonable
689+
>
690+
<
691+
input
692+
>
693+
<
694+
/
695+
template
696+
>
697+
<
698+
/
699+
div
700+
>
701+
'
702+
)
703+
;
704+
const
705+
root
706+
=
707+
div
708+
.
709+
firstElementChild
710+
.
711+
shadowRoot
712+
;
713+
assert_true
714+
(
715+
!
716+
!
717+
root
718+
)
719+
;
720+
assert_true
721+
(
722+
root
723+
.
724+
clonable
725+
"
726+
clonable
727+
gets
728+
added
729+
when
730+
shadowrootclonable
731+
is
732+
present
733+
"
734+
)
735+
;
736+
const
737+
clone
738+
=
739+
div
740+
.
741+
cloneNode
742+
(
743+
true
744+
)
745+
;
746+
const
747+
clonedRoot
748+
=
749+
clone
750+
.
751+
firstElementChild
752+
.
753+
shadowRoot
754+
;
755+
assert_true
756+
(
757+
!
626758
!
627759
clonedRoot
628760
)
@@ -665,11 +797,13 @@
665797
declarative
666798
shadow
667799
roots
668-
get
800+
can
801+
opt
802+
in
803+
to
669804
clonable
670-
:
671-
true
672-
automatically
805+
with
806+
shadowrootclonable
673807
"
674808
)
675809
;
@@ -791,41 +925,14 @@
791925
assert_true
792926
(
793927
!
794-
!
795-
clonedRoot
796-
)
797-
;
798-
assert_equals
799-
(
800-
clonedRoot
801-
.
802-
children
803-
.
804-
length
805-
1
806-
"
807-
children
808-
count
809-
"
810-
)
811-
;
812-
assert_equals
813-
(
814928
clonedRoot
815-
.
816-
children
817-
[
818-
0
819-
]
820-
.
821-
localName
822-
"
823-
input
824-
"
825-
"
826-
children
827-
content
828-
"
929+
'
930+
no
931+
shadow
932+
root
933+
gets
934+
cloned
935+
'
829936
)
830937
;
831938
}
@@ -835,7 +942,10 @@
835942
roots
836943
inside
837944
templates
838-
also
945+
do
946+
*
947+
not
948+
*
839949
get
840950
cloned
841951
automatically

0 commit comments

Comments
 (0)
Please sign in to comment.