diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index d346e97a40e..28e57417c84 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -487,7 +487,7 @@ impl<'le> ::selectors::Element for LayoutElement<'le> { #[inline] fn get_id(&self) -> Option { unsafe { - (*self.element.unsafe_get()).get_attr_atom_for_layout(&ns!(""), &atom!("id")) + (*self.element.id_attribute()).clone() } } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 0ca9c3c3f90..bedce2ed975 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -494,6 +494,7 @@ pub trait LayoutElementHelpers { unsafe fn html_element_in_html_document_for_layout(&self) -> bool; #[allow(unsafe_code)] unsafe fn has_attr_for_layout(&self, namespace: &Namespace, name: &Atom) -> bool; + fn id_attribute(&self) -> *const Option; fn style_attribute(&self) -> *const Option; fn local_name(&self) -> &Atom; fn namespace(&self) -> &Namespace; @@ -517,6 +518,13 @@ impl LayoutElementHelpers for LayoutJS { get_attr_for_layout(&*self.unsafe_get(), namespace, name).is_some() } + #[allow(unsafe_code)] + fn id_attribute(&self) -> *const Option { + unsafe { + (*self.unsafe_get()).id_attribute.borrow_for_layout() + } + } + #[allow(unsafe_code)] fn style_attribute(&self) -> *const Option { unsafe {