Skip to content

Commit

Permalink
Add a lifetime parameter to the ElementHelper trait
Browse files Browse the repository at this point in the history
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 committed Oct 1, 2014
1 parent 4ef0f39 commit be9618d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions components/script/dom/element.rs
Expand Up @@ -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> {
Expand Down

0 comments on commit be9618d

Please sign in to comment.