Skip to content

Commit ebc83f7

Browse files
committed
DOM: latest DocumentFragment adoption changes
See whatwg/dom#819. Verified with jsdom/jsdom#2925.
1 parent 0734d74 commit ebc83f7

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

custom-elements/adopted-callback.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127

128128
calls = [];
129129
doc.documentElement.appendChild(shadowRoot);
130-
assert_array_equals(calls, ['disconnected', 'adopted', document, doc, 'connected']);
130+
assert_array_equals(calls, ['adopted', document, doc, 'disconnected', 'connected']);
131131
});
132132
}, 'Moving the shadow host\'s shadow of a custom element from the owner document into ' + documentName + ' must enqueue and invoke adoptedCallback');
133133

dom/nodes/adoption.window.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,30 +29,34 @@ test(() => {
2929
"name": "ShadowRoot",
3030
"creator": doc => doc.createElementNS("http://www.w3.org/1999/xhtml", "div").attachShadow({mode: "closed"})
3131
}
32-
].forEach(dfTest => {
32+
].forEach(({ name, creator }) => {
3333
test(() => {
3434
const doc = new Document();
35-
const df = dfTest.creator(doc);
35+
const df = creator(doc);
3636
const child = df.appendChild(new Text('hi'));
3737
assert_equals(df.ownerDocument, doc);
3838

3939
document.body.appendChild(df);
4040
assert_equals(df.childNodes.length, 0);
4141
assert_equals(child.ownerDocument, document);
42-
assert_equals(df.ownerDocument, doc);
43-
}, `appendChild() and ${dfTest.name}`);
42+
if (name === "ShadowRoot") {
43+
assert_equals(df.ownerDocument, doc);
44+
} else {
45+
assert_equals(df.ownerDocument, document);
46+
}
47+
}, `appendChild() and ${name}`);
4448

4549
test(() => {
4650
const doc = new Document();
47-
const df = dfTest.creator(doc);
51+
const df = creator(doc);
4852
const child = df.appendChild(new Text('hi'));
49-
if (dfTest.name === "ShadowRoot") {
53+
if (name === "ShadowRoot") {
5054
assert_throws_dom("HierarchyRequestError", () => document.adoptNode(df));
5155
} else {
5256
document.adoptNode(df);
5357
assert_equals(df.childNodes.length, 1);
5458
assert_equals(child.ownerDocument, document);
5559
assert_equals(df.ownerDocument, document);
5660
}
57-
}, `adoptNode() and ${dfTest.name}`);
61+
}, `adoptNode() and ${name}`);
5862
});

0 commit comments

Comments
 (0)