diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-01-17 10:57:06 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-17 10:57:06 -0600 |
commit | fa82a6bbcef23c1ff4dc9d34f5f4ad75b622b3be (patch) | |
tree | e8ce9669b2f3b0786480c83dda9e2944163ff1b8 /components/script/dom/servoparser/async_html.rs | |
parent | 8a740aa4d1e75aad9308e3eb805ed3e15078fb59 (diff) | |
parent | c55f25b3aaeea7719f0864b1e6c1e71af7f05340 (diff) | |
download | servo-fa82a6bbcef23c1ff4dc9d34f5f4ad75b622b3be.tar.gz servo-fa82a6bbcef23c1ff4dc9d34f5f4ad75b622b3be.zip |
Auto merge of #19397 - cbrewster:create_element_for_token, r=jdm,nox
Implement the create an element for token algorithm
<!-- Please describe your changes on the following line: -->
---
<!-- 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 #19392 and fix #19393 (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- 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. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19397)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/servoparser/async_html.rs')
-rw-r--r-- | components/script/dom/servoparser/async_html.rs | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/components/script/dom/servoparser/async_html.rs b/components/script/dom/servoparser/async_html.rs index c918a4b3605..bcf3e25b767 100644 --- a/components/script/dom/servoparser/async_html.rs +++ b/components/script/dom/servoparser/async_html.rs @@ -12,14 +12,15 @@ use dom::bindings::str::DOMString; use dom::comment::Comment; use dom::document::Document; use dom::documenttype::DocumentType; -use dom::element::{CustomElementCreationMode, Element, ElementCreator}; +use dom::element::{Element, ElementCreator}; use dom::htmlformelement::{FormControlElementHelpers, HTMLFormElement}; use dom::htmlscriptelement::HTMLScriptElement; use dom::htmltemplateelement::HTMLTemplateElement; use dom::node::Node; use dom::processinginstruction::ProcessingInstruction; +use dom::servoparser::{ElementAttribute, create_element_for_token, ParsingAlgorithm}; use dom::virtualmethods::vtable_for; -use html5ever::{Attribute as HtmlAttribute, ExpandedName, LocalName, QualName}; +use html5ever::{Attribute as HtmlAttribute, ExpandedName, QualName}; use html5ever::buffer_queue::BufferQueue; use html5ever::tendril::{SendTendril, StrTendril, Tendril}; use html5ever::tendril::fmt::UTF8; @@ -335,20 +336,18 @@ impl Tokenizer { self.insert_node(contents, Dom::from_ref(template.Content().upcast())); } ParseOperation::CreateElement { node, name, attrs, current_line } => { - let is = attrs.iter() - .find(|attr| attr.name.local.eq_str_ignore_ascii_case("is")) - .map(|attr| LocalName::from(&*attr.value)); - - let elem = Element::create(name, - is, - &*self.document, - ElementCreator::ParserCreated(current_line), - CustomElementCreationMode::Synchronous); - for attr in attrs { - elem.set_attribute_from_parser(attr.name, DOMString::from(attr.value), None); - } - - self.insert_node(node, Dom::from_ref(elem.upcast())); + let attrs = attrs + .into_iter() + .map(|attr| ElementAttribute::new(attr.name, DOMString::from(attr.value))) + .collect(); + let element = create_element_for_token( + name, + attrs, + &*self.document, + ElementCreator::ParserCreated(current_line), + ParsingAlgorithm::Normal + ); + self.insert_node(node, Dom::from_ref(element.upcast())); } ParseOperation::CreateComment { text, node } => { let comment = Comment::new(DOMString::from(text), document); |