diff options
Diffstat (limited to 'components/script/dom/customelementregistry.rs')
-rw-r--r-- | components/script/dom/customelementregistry.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index 100aae7cae3..a625d464129 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -18,7 +18,7 @@ use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::document::Document; use dom::domexception::{DOMErrorName, DOMException}; -use dom::element::Element; +use dom::element::{CustomElementState, Element}; use dom::globalscope::GlobalScope; use dom::htmlelement::HTMLElement; use dom::node::{document_from_node, Node, window_from_node}; @@ -477,8 +477,11 @@ impl CustomElementDefinition { /// https://html.spec.whatwg.org/multipage/#concept-upgrade-an-element #[allow(unsafe_code)] pub fn upgrade_element(definition: Rc<CustomElementDefinition>, element: &Element) { - // TODO: Steps 1-2 - // Track custom element state + // Steps 1-2 + let state = element.get_custom_element_state(); + if state == CustomElementState::Custom || state == CustomElementState::Failed { + return; + } // Step 3 for attr in element.attrs().iter() { @@ -504,8 +507,8 @@ pub fn upgrade_element(definition: Rc<CustomElementDefinition>, element: &Elemen // Step 7 exception handling if let Err(error) = result { - // TODO: Step 7.1 - // Track custom element state + // Step 7.1 + element.set_custom_element_state(CustomElementState::Failed); // Step 7.2 element.clear_reaction_queue(); @@ -520,6 +523,10 @@ pub fn upgrade_element(definition: Rc<CustomElementDefinition>, element: &Elemen return; } + // Step 8 + element.set_custom_element_state(CustomElementState::Custom); + + // Step 9 element.set_custom_element_definition(definition); } |