Skip to content
Permalink
Browse files

Add a lifetime parameter to the ElementHelper trait

This refines the lifetime used in get_local_name / get_namespace and
makes it independent of the lifetime on the &self parameter.
  • Loading branch information
Cameron Zwarich
Cameron Zwarich committed Oct 1, 2014
1 parent 4ef0f39 commit be9618d55bd48be45e55b2c49d0df12f953f1fe5
Showing with 8 additions and 8 deletions.
  1. +8 −8 components/script/dom/element.rs
@@ -237,26 +237,26 @@ impl LayoutElementHelpers for JS<Element> {
}
}

pub trait ElementHelpers {
pub trait ElementHelpers<'a> {
fn html_element_in_html_document(self) -> bool;
fn get_local_name<'a>(&'a self) -> &'a Atom;
fn get_namespace<'a>(&'a self) -> &'a Namespace;
fn get_local_name(&self) -> &'a Atom;
fn get_namespace(&self) -> &'a Namespace;
fn summarize(self) -> Vec<AttrInfo>;
fn is_void(self) -> bool;
}

impl<'a> ElementHelpers for JSRef<'a, Element> {
impl<'a> ElementHelpers<'a> for JSRef<'a, Element> {
fn html_element_in_html_document(self) -> bool {
let node: JSRef<Node> = NodeCast::from_ref(self);
self.namespace == ns!(HTML) && node.is_in_html_doc()
}

fn get_local_name<'a>(&'a self) -> &'a Atom {
&self.deref().local_name
fn get_local_name(&self) -> &'a Atom {
&self.extended_deref().local_name
}

fn get_namespace<'a>(&'a self) -> &'a Namespace {
&self.deref().namespace
fn get_namespace(&self) -> &'a Namespace {
&self.extended_deref().namespace
}

fn summarize(self) -> Vec<AttrInfo> {

0 comments on commit be9618d

Please sign in to comment.
You can’t perform that action at this time.