CustomElementRegistry.upgrade works by current spec

This commit is contained in:
Patrick Shaughnessy 2019-12-31 21:02:27 -05:00
parent 45cc558297
commit 065bcee371
4 changed files with 13 additions and 15 deletions

View file

@ -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)]

View file

@ -11,6 +11,8 @@ interface CustomElementRegistry {
any get(DOMString name);
Promise<void> whenDefined(DOMString name);
[CEReactions] void upgrade(Node root);
};
callback CustomElementConstructor = HTMLElement();

View file

@ -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

View file

@ -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