Repository: servo/servo
File: components/script/dom/servoparser/mod.rs (Rust)

Code before:
        CustomElementCreationMode::Synchronous
    } else {
        CustomElementCreationMode::Asynchronous
    };
    let element = Element::create(name, is, document, creator, creation_mode, None, can_gc);

    // Step 11. Append each attribute in the given token to element.
    for attr in attrs {
        element.set_attribute_from_parser(attr.name, attr.value, None, can_gc);
    }

    // Step 12. If willExecuteScript is true:
    if will_execute_script {
        // Step 12.1. Let queue be the result of popping from document's relevant agent's
        // custom element reactions stack. (This will be the same element queue as was
        // pushed above.)
        // Step 12.2 Invoke custom element reactions in queue.
        custom_element_reaction_stack.pop_current_element_queue(can_gc);
        // Step 12.3. Decrement document's throw-on-dynamic-markup-insertion counter.
        document.decrement_throw_on_dynamic_markup_insertion_counter();
    }

    // Step 13. If element has an xmlns attribute in the XMLNS namespace whose value is
    // not exactly the same as the element's namespace, that is a parse error. Similarly,
    // if element has an xmlns:xlink attribute in the XMLNS namespace whose value is not
    // the XLink Namespace, that is a parse error.0w
    // TODO: Implement.

    // Step 14. If element is a resettable element and not a form-associated custom
    // element, then invoke its reset algorithm. (This initializes the element's value and
    // checkedness based on the element's attributes.)
    if let Some(html_element) = element.downcast::<HTMLElement>() {
        if element.is_resettable() && !html_element.is_form_associated_custom_element() {
            element.reset(can_gc);
        }
    }

    // Step 15. If element is a form-associated element and not a form-associated custom
    // element, the form element pointer is not null, there is no template element on the
    // stack of open elements, element is either not listed or doesn't have a form attribute,
    // and the intendedParent is in the same tree as the element pointed to by the form
    // element pointer, then associate element with the form element pointed to by the form
    // element pointer and set element's parser inserted flag.
    // TODO: Implement

    // Step 16. Return element.
    element
}

fn attach_declarative_shadow_inner(host: &Node, template: &Node, attributes: &[Attribute]) -> bool {
    let host_element = host.downcast::<Element>().unwrap();

Review comment (suggestion):
```suggestion
    // the XLink Namespace, that is a parse error.
```

Code after:
        CustomElementCreationMode::Synchronous
    } else {
        CustomElementCreationMode::Asynchronous
    };
    let element = Element::create(name, is, document, creator, creation_mode, None, can_gc);

    // Step 11. Append each attribute in the given token to element.
    for attr in attrs {
        element.set_attribute_from_parser(attr.name, attr.value, None, can_gc);
    }

    // Step 12. If willExecuteScript is true:
    if will_execute_script {
        // Step 12.1. Let queue be the result of popping from document's relevant agent's
        // custom element reactions stack. (This will be the same element queue as was
        // pushed above.)
        // Step 12.2 Invoke custom element reactions in queue.
        custom_element_reaction_stack.pop_current_element_queue(can_gc);
        // Step 12.3. Decrement document's throw-on-dynamic-markup-insertion counter.
        document.decrement_throw_on_dynamic_markup_insertion_counter();
    }

    // Step 13. If element has an xmlns attribute in the XMLNS namespace whose value is
    // not exactly the same as the element's namespace, that is a parse error. Similarly,
    // if element has an xmlns:xlink attribute in the XMLNS namespace whose value is not
    // the XLink Namespace, that is a parse error.
    // TODO: Implement.

    // Step 14. If element is a resettable element and not a form-associated custom
    // element, then invoke its reset algorithm. (This initializes the element's value and
    // checkedness based on the element's attributes.)
    if let Some(html_element) = element.downcast::<HTMLElement>() {
        if element.is_resettable() && !html_element.is_form_associated_custom_element() {
            element.reset(can_gc);
        }
    }

    // Step 15. If element is a form-associated element and not a form-associated custom
    // element, the form element pointer is not null, there is no template element on the
    // stack of open elements, element is either not listed or doesn't have a form attribute,
    // and the intendedParent is in the same tree as the element pointed to by the form
    // element pointer, then associate element with the form element pointed to by the form
    // element pointer and set element's parser inserted flag.
    // TODO: Implement

    // Step 16. Return element.
    element
}

fn attach_declarative_shadow_inner(host: &Node, template: &Node, attributes: &[Attribute]) -> bool {
    let host_element = host.downcast::<Element>().unwrap();