Fix cloning of Element's attributes

No virtual method was invoked when copies of attributes were appended to
newly-cloned elements.
This commit is contained in:
Anthony Ramine 2015-09-12 17:17:22 +02:00
parent d5ee58caf2
commit 650afc9d3e
4 changed files with 10 additions and 56 deletions

View file

@ -83,7 +83,7 @@ use url::UrlParser;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use std::borrow::{Cow, ToOwned}; use std::borrow::{Cow, ToOwned};
use std::cell::{Ref, RefMut}; use std::cell::Ref;
use std::default::Default; use std::default::Default;
use std::mem; use std::mem;
use std::sync::Arc; use std::sync::Arc;
@ -597,10 +597,6 @@ impl Element {
self.attrs.borrow() self.attrs.borrow()
} }
pub fn attrs_mut(&self) -> RefMut<Vec<JS<Attr>>> {
self.attrs.borrow_mut()
}
pub fn style_attribute(&self) -> &DOMRefCell<Option<PropertyDeclarationBlock>> { pub fn style_attribute(&self) -> &DOMRefCell<Option<PropertyDeclarationBlock>> {
&self.style_attribute &self.style_attribute
} }

View file

@ -1768,15 +1768,12 @@ impl Node {
let node_elem = ElementCast::to_ref(node).unwrap(); let node_elem = ElementCast::to_ref(node).unwrap();
let copy_elem = ElementCast::to_ref(copy.r()).unwrap(); let copy_elem = ElementCast::to_ref(copy.r()).unwrap();
let window = document.r().window(); for attr in node_elem.attrs().iter().map(JS::root) {
for ref attr in &*node_elem.attrs() { copy_elem.push_new_attribute(attr.local_name().clone(),
let attr = attr.root(); attr.value().clone(),
let newattr = attr.name().clone(),
Attr::new(window.r(), attr.namespace().clone(),
attr.r().local_name().clone(), attr.r().value().clone(), attr.prefix().clone());
attr.r().name().clone(), attr.r().namespace().clone(),
attr.r().prefix().clone(), Some(copy_elem));
copy_elem.attrs_mut().push(JS::from_rooted(&newattr));
} }
}, },
_ => () _ => ()

View file

@ -27,12 +27,6 @@
[Detached Element.matches: :lang pseudo-class selector, matching specified language with partial value (with no refNodes): #pseudo-lang-div3:lang(en)] [Detached Element.matches: :lang pseudo-class selector, matching specified language with partial value (with no refNodes): #pseudo-lang-div3:lang(en)]
expected: FAIL expected: FAIL
[Detached Element.matches: :enabled pseudo-class selector, matching all disabled form controls (with no refNodes): #pseudo-ui :disabled]
expected: FAIL
[Detached Element.matches: :checked pseudo-class selector, matching checked radio buttons and checkboxes (with no refNodes): #pseudo-ui :checked]
expected: FAIL
[Fragment Element.matches: Attribute hyphen-separated list selector, matching lang attribute with partial value (with no refNodes): #attr-hyphen-div3[lang|="en"\]] [Fragment Element.matches: Attribute hyphen-separated list selector, matching lang attribute with partial value (with no refNodes): #attr-hyphen-div3[lang|="en"\]]
expected: FAIL expected: FAIL
@ -42,12 +36,6 @@
[Fragment Element.matches: :lang pseudo-class selector, matching specified language with partial value (with no refNodes): #pseudo-lang-div3:lang(en)] [Fragment Element.matches: :lang pseudo-class selector, matching specified language with partial value (with no refNodes): #pseudo-lang-div3:lang(en)]
expected: FAIL expected: FAIL
[Fragment Element.matches: :enabled pseudo-class selector, matching all disabled form controls (with no refNodes): #pseudo-ui :disabled]
expected: FAIL
[Fragment Element.matches: :checked pseudo-class selector, matching checked radio buttons and checkboxes (with no refNodes): #pseudo-ui :checked]
expected: FAIL
[In-document Element.matches: Universal selector, matching all children of the specified reference element (with refNode Element): >*] [In-document Element.matches: Universal selector, matching all children of the specified reference element (with refNode Element): >*]
expected: FAIL expected: FAIL

View file

@ -120,21 +120,6 @@
[Detached Element.querySelector: :lang pseudo-class selector, not matching incorrect language: #pseudo-lang-div4:lang(es-AR)] [Detached Element.querySelector: :lang pseudo-class selector, not matching incorrect language: #pseudo-lang-div4:lang(es-AR)]
expected: FAIL expected: FAIL
[Detached Element.querySelectorAll: :enabled pseudo-class selector, matching all enabled form controls: #pseudo-ui :enabled]
expected: FAIL
[Detached Element.querySelectorAll: :enabled pseudo-class selector, matching all disabled form controls: #pseudo-ui :disabled]
expected: FAIL
[Detached Element.querySelector: :enabled pseudo-class selector, matching all disabled form controls: #pseudo-ui :disabled]
expected: FAIL
[Detached Element.querySelectorAll: :checked pseudo-class selector, matching checked radio buttons and checkboxes: #pseudo-ui :checked]
expected: FAIL
[Detached Element.querySelector: :checked pseudo-class selector, matching checked radio buttons and checkboxes: #pseudo-ui :checked]
expected: FAIL
[Detached Element.querySelectorAll: :first-line pseudo-element (one-colon syntax) selector, not matching any elements: #pseudo-element:first-line] [Detached Element.querySelectorAll: :first-line pseudo-element (one-colon syntax) selector, not matching any elements: #pseudo-element:first-line]
expected: FAIL expected: FAIL
@ -201,21 +186,6 @@
[Fragment.querySelector: :lang pseudo-class selector, not matching incorrect language: #pseudo-lang-div4:lang(es-AR)] [Fragment.querySelector: :lang pseudo-class selector, not matching incorrect language: #pseudo-lang-div4:lang(es-AR)]
expected: FAIL expected: FAIL
[Fragment.querySelectorAll: :enabled pseudo-class selector, matching all enabled form controls: #pseudo-ui :enabled]
expected: FAIL
[Fragment.querySelectorAll: :enabled pseudo-class selector, matching all disabled form controls: #pseudo-ui :disabled]
expected: FAIL
[Fragment.querySelector: :enabled pseudo-class selector, matching all disabled form controls: #pseudo-ui :disabled]
expected: FAIL
[Fragment.querySelectorAll: :checked pseudo-class selector, matching checked radio buttons and checkboxes: #pseudo-ui :checked]
expected: FAIL
[Fragment.querySelector: :checked pseudo-class selector, matching checked radio buttons and checkboxes: #pseudo-ui :checked]
expected: FAIL
[Fragment.querySelectorAll: :first-line pseudo-element (one-colon syntax) selector, not matching any elements: #pseudo-element:first-line] [Fragment.querySelectorAll: :first-line pseudo-element (one-colon syntax) selector, not matching any elements: #pseudo-element:first-line]
expected: FAIL expected: FAIL
@ -759,3 +729,6 @@
[In-document Element.querySelectorAll: Syntax, group of selectors separator, no whitespace: #group em,#group strong] [In-document Element.querySelectorAll: Syntax, group of selectors separator, no whitespace: #group em,#group strong]
expected: FAIL expected: FAIL
[In-document Element.querySelectorAll: :enabled pseudo-class selector, matching all disabled form controls: #pseudo-ui :disabled]
expected: FAIL