diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index c25c9d4d611..aef9d65e5ff 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -101,7 +101,7 @@ pub struct Attr { value: DOMRefCell, name: Atom, namespace: Namespace, - prefix: Option, + prefix: Option, /// the element that owns this attribute. owner: MutNullableHeap>, @@ -116,7 +116,7 @@ impl Attr { value: DOMRefCell::new(value), name: name, namespace: namespace, - prefix: prefix, + prefix: prefix.map(|p| Atom::from_slice(&p)), owner: MutNullableHeap::new(owner.map(JS::from_rooted)), } } @@ -141,7 +141,7 @@ impl Attr { } #[inline] - pub fn prefix<'a>(&'a self) -> &'a Option { + pub fn prefix<'a>(&'a self) -> &'a Option { &self.prefix } } @@ -205,7 +205,7 @@ impl<'a> AttrMethods for JSRef<'a, Attr> { // https://dom.spec.whatwg.org/#dom-attr-prefix fn GetPrefix(self) -> Option { - self.prefix.clone() + self.prefix().as_ref().map(|p| (**p).to_owned()) } // https://dom.spec.whatwg.org/#dom-attr-ownerelement diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 525130af9fc..8d5c2184c0f 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1778,7 +1778,7 @@ impl Node { &Attr::new(window.r(), attr.r().local_name().clone(), attr.r().value().clone(), attr.r().name().clone(), attr.r().namespace().clone(), - attr.r().prefix().clone(), Some(copy_elem))); + attr.r().GetPrefix(), Some(copy_elem))); } }, _ => ()