Skip to content

Commit ff0b14e

Browse files
DOM: Enable moveBefore() inside ShadowRoot DocumentFragments
This CL enables moveBefore() inside connected ShadowRoot DocumentFragments, as the general only-Element-node target parent pre-condition was too strict, and disabled this case, despite it being a pretty valid one. This was discussed in whatwg/dom#1307 (comment). [email protected] Bug: 40150299 Change-Id: Ie9c6e31400b75b2b5d10d095c059012056a440da Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6012161 Commit-Queue: Dominic Farolino <[email protected]> Reviewed-by: Noam Rosenthal <[email protected]> Cr-Commit-Position: refs/heads/main@{#1381208}
1 parent d675a64 commit ff0b14e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<script src="/resources/testharness.js"></script>
3+
<script src="/resources/testharnessreport.js"></script>
4+
5+
<body>
6+
<div id=shadowTarget></div>
7+
</body>
8+
9+
<script>
10+
test(() => {
11+
shadowTarget.attachShadow({mode: 'open'});
12+
const child1 = document.createElement('p');
13+
child1.textContent = 'Child1';
14+
const child2 = document.createElement('p');
15+
child2.textContent = 'Child2';
16+
17+
shadowTarget.shadowRoot.append(child1, child2);
18+
shadowTarget.shadowRoot.moveBefore(child2, child1);
19+
assert_equals(shadowTarget.shadowRoot.firstChild, child2, "Original lastChild is now firstChild");
20+
assert_equals(shadowTarget.shadowRoot.lastChild, child1, "Original firstChild is now lastChild");
21+
}, "moveBefore() is allowed in ShadowRoots (i.e., connected DocumentFragments)");
22+
</script>

0 commit comments

Comments
 (0)