Auto merge of #17421 - cbrewster:set_attribute_node_fix, r=emilio

Fix crash when id attribute is set via SetAttributeNode

fixes #17366
<!-- 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/17421)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-21 01:04:18 -07:00 committed by GitHub
commit 82884050be
3 changed files with 30 additions and 0 deletions

View file

@ -1543,6 +1543,10 @@ impl ElementMethods for Element {
// https://dom.spec.whatwg.org/#dom-element-setattributenode
fn SetAttributeNode(&self, attr: &Attr) -> Fallible<Option<Root<Attr>>> {
// Workaround for https://github.com/servo/servo/issues/17366
// This ensures that if this is an "id" attr, its value is an Atom
attr.swap_value(&mut self.parse_plain_attribute(attr.local_name(), attr.Value()));
// Step 1.
if let Some(owner) = attr.GetOwnerElement() {
if &*owner != self {