Skip to content

Commit

Permalink
Make Attr::prefix return an Option<&Prefix>
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Dec 1, 2016
1 parent a377caa commit fb206e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions components/script/dom/attr.rs
Expand Up @@ -81,8 +81,8 @@ impl Attr {
}

#[inline]
pub fn prefix(&self) -> &Option<Prefix> {
&self.identifier.prefix
pub fn prefix(&self) -> Option<&Prefix> {
self.identifier.prefix.as_ref()
}
}

Expand Down Expand Up @@ -153,7 +153,7 @@ impl AttrMethods for Attr {
// https://dom.spec.whatwg.org/#dom-attr-prefix
fn GetPrefix(&self) -> Option<DOMString> {
// 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
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/element.rs
Expand Up @@ -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());
}
Expand Down
6 changes: 3 additions & 3 deletions components/script/dom/node.rs
Expand Up @@ -1768,7 +1768,7 @@ impl Node {
attr.value().clone(),
attr.name().clone(),
attr.namespace().clone(),
attr.prefix().clone());
attr.prefix().cloned());
}
},
_ => ()
Expand Down Expand Up @@ -1815,10 +1815,10 @@ impl Node {
defined_prefix: &Option<LocalName>) -> 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
}
}
Expand Down

0 comments on commit fb206e2

Please sign in to comment.