Skip to content

Commit 9835170

Browse files
committed
CustomElementRegistry.upgrade works by current spec
1 parent 90acd1a commit 9835170

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

components/script/dom/customelementregistry.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,17 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
448448
// Step 6
449449
promise
450450
}
451+
/// https://html.spec.whatwg.org/multipage/#dom-customelementregistry-upgrade
452+
fn Upgrade(&self, node: &Node) {
453+
// Spec says to make a list first and then iterate the list, but
454+
// try-to-upgrade only queues upgrade reactions and doesn't itself
455+
// modify the tree, so that's not an observable distinction.
456+
node.traverse_preorder(ShadowIncluding::Yes).for_each(|n| {
457+
if let Some(element) = n.downcast::<Element>() {
458+
try_upgrade_element(element);
459+
}
460+
});
461+
}
451462
}
452463

453464
#[derive(Clone, JSTraceable, MallocSizeOf)]

components/script/dom/webidls/CustomElementRegistry.webidl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ interface CustomElementRegistry {
1111
any get(DOMString name);
1212

1313
Promise<void> whenDefined(DOMString name);
14+
15+
[CEReactions] void upgrade(Node root);
1416
};
1517

1618
callback CustomElementConstructor = HTMLElement();
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
[upgrade.html]
2-
[Upgrading an element directly (example from the spec)]
3-
expected: FAIL
4-
5-
[Two elements as children of the upgraded node]
6-
expected: FAIL
7-
8-
[Two elements as descendants of the upgraded node]
9-
expected: FAIL
10-
112
[Two elements as shadow-including descendants (and not descendants) of the upgraded node]
123
expected: FAIL
134

14-
[Elements inside a template contents DocumentFragment node]
15-
expected: FAIL
16-

0 commit comments

Comments
 (0)