Introduce AttrHelpersForLayout::namespace

This commit is contained in:
Anthony Ramine 2020-03-31 14:06:22 +02:00
parent 47c9f19121
commit 3e875ce3eb
2 changed files with 7 additions and 1 deletions

View file

@ -238,6 +238,7 @@ pub trait AttrHelpersForLayout<'dom> {
fn as_str(self) -> &'dom str;
fn as_tokens(self) -> Option<&'dom [Atom]>;
fn local_name(self) -> &'dom LocalName;
fn namespace(self) -> &'dom Namespace;
}
#[allow(unsafe_code)]
@ -265,4 +266,9 @@ impl<'dom> AttrHelpersForLayout<'dom> for LayoutDom<'dom, Attr> {
fn local_name(self) -> &'dom LocalName {
unsafe { &self.unsafe_get().identifier.local_name }
}
#[inline]
fn namespace(self) -> &'dom Namespace {
unsafe { &self.unsafe_get().identifier.namespace }
}
}

View file

@ -578,7 +578,7 @@ pub unsafe fn get_attr_for_layout<'dom>(
.iter()
.find(|attr| {
let attr = attr.to_layout();
name == attr.local_name() && (*attr.unsafe_get()).namespace() == namespace
name == attr.local_name() && namespace == attr.namespace()
})
.map(|attr| attr.to_layout())
}