mirror of
https://github.com/servo/servo.git
synced 2025-09-30 16:49:16 +01:00
script: use Element::create
instead of DOM struct constructors (#39325)
Creating elements by directly calling their interface constructors leads to some state not being intialized correctly (see #39285). It is also not in line with the specifications as many of them refer to the [`create an element`][1] algorithm when an element needs to be created, which directly maps to `Element::create` in the script crate. So, switch all such places where elements are created by script to use `Element::create`. [1]: https://dom.spec.whatwg.org/#concept-create-element Testing: Existing WPT tests. Fixes: #39285 Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
parent
2b261b02bf
commit
07b2ff5d60
13 changed files with 254 additions and 98 deletions
|
@ -7,7 +7,7 @@ use std::default::Default;
|
|||
use std::rc::Rc;
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{LocalName, Prefix, local_name, ns};
|
||||
use html5ever::{LocalName, Prefix, QualName, local_name, ns};
|
||||
use js::rust::HandleObject;
|
||||
use layout_api::{QueryMsg, ScrollContainerQueryType, ScrollContainerResponse};
|
||||
use script_bindings::codegen::GenericBindings::DocumentBinding::DocumentMethods;
|
||||
|
@ -36,12 +36,11 @@ use crate::dom::customelementregistry::{CallbackReaction, CustomElementState};
|
|||
use crate::dom::document::{Document, FocusInitiator};
|
||||
use crate::dom::documentfragment::DocumentFragment;
|
||||
use crate::dom::domstringmap::DOMStringMap;
|
||||
use crate::dom::element::{AttributeMutation, Element};
|
||||
use crate::dom::element::{AttributeMutation, CustomElementCreationMode, Element, ElementCreator};
|
||||
use crate::dom::elementinternals::ElementInternals;
|
||||
use crate::dom::event::Event;
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::html::htmlbodyelement::HTMLBodyElement;
|
||||
use crate::dom::html::htmlbrelement::HTMLBRElement;
|
||||
use crate::dom::html::htmldetailselement::HTMLDetailsElement;
|
||||
use crate::dom::html::htmlformelement::{FormControl, HTMLFormElement};
|
||||
use crate::dom::html::htmlframesetelement::HTMLFrameSetElement;
|
||||
|
@ -1060,7 +1059,15 @@ impl HTMLElement {
|
|||
text = String::new();
|
||||
}
|
||||
|
||||
let br = HTMLBRElement::new(local_name!("br"), None, &document, None, can_gc);
|
||||
let br = Element::create(
|
||||
QualName::new(None, ns!(html), local_name!("br")),
|
||||
None,
|
||||
&document,
|
||||
ElementCreator::ScriptCreated,
|
||||
CustomElementCreationMode::Asynchronous,
|
||||
None,
|
||||
can_gc,
|
||||
);
|
||||
fragment
|
||||
.upcast::<Node>()
|
||||
.AppendChild(br.upcast(), can_gc)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue