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();