From fb206e2b1020bd40122a48affc04f6b9f6352d39 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Wed, 30 Nov 2016 13:57:22 +0100 Subject: [PATCH] Make Attr::prefix return an Option<&Prefix> --- components/script/dom/attr.rs | 6 +++--- components/script/dom/element.rs | 2 +- components/script/dom/node.rs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 2aae65af920..8b9587c9151 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -81,8 +81,8 @@ impl Attr { } #[inline] - pub fn prefix(&self) -> &Option { - &self.identifier.prefix + pub fn prefix(&self) -> Option<&Prefix> { + self.identifier.prefix.as_ref() } } @@ -153,7 +153,7 @@ impl AttrMethods for Attr { // https://dom.spec.whatwg.org/#dom-attr-prefix fn GetPrefix(&self) -> Option { // FIXME(ajeffrey): convert directly from LocalName to DOMString - self.prefix().as_ref().map(|p| DOMString::from(&**p)) + self.prefix().map(|p| DOMString::from(&**p)) } // https://dom.spec.whatwg.org/#dom-attr-ownerelement diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 7ac6cafcc32..887aadd6bd3 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -820,7 +820,7 @@ impl Element { // Step 2. for attr in element.attrs.borrow().iter() { - if *attr.prefix() == Some(namespace_prefix!("xmlns")) && + if attr.prefix() == Some(&namespace_prefix!("xmlns")) && **attr.value() == *namespace { return Some(attr.LocalName()); } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index f47d2583ae5..2d2440db842 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1768,7 +1768,7 @@ impl Node { attr.value().clone(), attr.name().clone(), attr.namespace().clone(), - attr.prefix().clone()); + attr.prefix().cloned()); } }, _ => () @@ -1815,10 +1815,10 @@ impl Node { defined_prefix: &Option) -> bool { *attr.namespace() == ns!(xmlns) && match (attr.prefix(), defined_prefix) { - (&Some(ref attr_prefix), &Some(ref defined_prefix)) => + (Some(attr_prefix), &Some(ref defined_prefix)) => attr_prefix == &namespace_prefix!("xmlns") && attr.local_name() == defined_prefix, - (&None, &None) => *attr.local_name() == local_name!("xmlns"), + (None, &None) => *attr.local_name() == local_name!("xmlns"), _ => false } }