Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
CustomElementRegistry.upgrade works by current spec
  • Loading branch information
pshaughn committed Jan 2, 2020
1 parent 45cc558 commit 065bcee
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
11 changes: 11 additions & 0 deletions components/script/dom/customelementregistry.rs
Expand Up @@ -448,6 +448,17 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
// Step 6
promise
}
/// https://html.spec.whatwg.org/multipage/#dom-customelementregistry-upgrade
fn Upgrade(&self, node: &Node) {
// Spec says to make a list first and then iterate the list, but
// try-to-upgrade only queues upgrade reactions and doesn't itself
// modify the tree, so that's not an observable distinction.
node.traverse_preorder(ShadowIncluding::Yes).for_each(|n| {
if let Some(element) = n.downcast::<Element>() {
try_upgrade_element(element);
}
});
}
}

#[derive(Clone, JSTraceable, MallocSizeOf)]
Expand Down
2 changes: 2 additions & 0 deletions components/script/dom/webidls/CustomElementRegistry.webidl
Expand Up @@ -11,6 +11,8 @@ interface CustomElementRegistry {
any get(DOMString name);

Promise<void> whenDefined(DOMString name);

[CEReactions] void upgrade(Node root);
};

callback CustomElementConstructor = HTMLElement();
Expand Down
@@ -1,16 +1,4 @@
[upgrade.html]
[Upgrading an element directly (example from the spec)]
expected: FAIL

[Two elements as children of the upgraded node]
expected: FAIL

[Two elements as descendants of the upgraded node]
expected: FAIL

[Two elements as shadow-including descendants (and not descendants) of the upgraded node]
expected: FAIL

[Elements inside a template contents DocumentFragment node]
expected: FAIL

3 changes: 0 additions & 3 deletions tests/wpt/metadata/html/dom/idlharness.https.html.ini
Expand Up @@ -62,9 +62,6 @@
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "getTransform()" with the proper type]
expected: FAIL

[CustomElementRegistry interface: operation upgrade(Node)]
expected: FAIL

[OffscreenCanvasRenderingContext2D interface: attribute imageSmoothingEnabled]
expected: FAIL

Expand Down

0 comments on commit 065bcee

Please sign in to comment.