Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Document can be used when creating elements during parsing #18277

Open
cbrewster opened this issue Aug 28, 2017 · 1 comment
Open

Incorrect Document can be used when creating elements during parsing #18277

cbrewster opened this issue Aug 28, 2017 · 1 comment

Comments

@cbrewster
Copy link
Member

@cbrewster cbrewster commented Aug 28, 2017

Step 1 of https://html.spec.whatwg.org/multipage/#create-an-element-for-the-token states that the intended parent's node document should be used when creating a new element during parsing.

We currently use the document that is associated with the parser. (line 795)

fn create_element(&mut self, name: QualName, attrs: Vec<Attribute>, _flags: ElementFlags)
-> JS<Node> {
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(self.current_line),
CustomElementCreationMode::Synchronous);
for attr in attrs {
elem.set_attribute_from_parser(attr.name, DOMString::from(String::from(attr.value)), None);
}
JS::from_ref(elem.upcast())
}

This causes issues when creating an element that is supposed to be inside a template's contents because contents has a different document than the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.