Auto merge of #25410 - pshaughn:ceupgrade, r=jdm

Implement CustomElementRegistry.upgrade

<!-- Please describe your changes on the following line: -->
An additional small change will be needed if whatwg/html#5126 lands, which will pass an infinite recursion test this is currently failing in custom-elements/upgrading.html (right now the test is asking for behavior that isn't in the spec).
The remaining test in custom-elements/custom-element-registry/upgrade.html is because it needs shadow DOM.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #24989

<!-- Either: -->
- [X] There are tests for these changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
bors-servo 2020-01-03 02:57:01 -05:00 committed by GitHub
commit 171b543a8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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();