From b19165e9e1b35254b0e85a5e9fdea6a08b2fefbe Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 7 Apr 2014 17:47:32 +0200 Subject: [PATCH] Move SetAttribute onto JS. --- src/components/script/dom/element.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs index a9cee2c8650..c274deb96a6 100644 --- a/src/components/script/dom/element.rs +++ b/src/components/script/dom/element.rs @@ -198,6 +198,7 @@ pub trait AttributeHandlers { fn do_set_attribute(&mut self, local_name: DOMString, value: DOMString, name: DOMString, namespace: Namespace, prefix: Option, cb: |&JS| -> bool); + fn SetAttribute(&mut self, name: DOMString, value: DOMString) -> ErrorResult; fn after_set_attr(&mut self, local_name: DOMString, value: DOMString); fn remove_attribute(&mut self, namespace: Namespace, name: DOMString) -> ErrorResult; @@ -294,6 +295,17 @@ impl AttributeHandlers for JS { } } + // http://dom.spec.whatwg.org/#dom-element-setattribute + fn SetAttribute(&mut self, name: DOMString, value: DOMString) -> ErrorResult { + // FIXME: If name does not match the Name production in XML, throw an "InvalidCharacterError" exception. + let name = if self.get().html_element_in_html_document() { + name.to_ascii_lower() + } else { + name + }; + self.set_attr(name, value) + } + fn after_set_attr(&mut self, local_name: DOMString, value: DOMString) { let node: JS = NodeCast::from(self); match local_name.as_slice() { @@ -515,16 +527,10 @@ impl Element { } // http://dom.spec.whatwg.org/#dom-element-setattribute - pub fn SetAttribute(&mut self, abstract_self: &mut JS, + pub fn SetAttribute(&self, abstract_self: &mut JS, name: DOMString, value: DOMString) -> ErrorResult { - // FIXME: If name does not match the Name production in XML, throw an "InvalidCharacterError" exception. - let name = if self.html_element_in_html_document() { - name.to_ascii_lower() - } else { - name - }; - abstract_self.set_attr(name, value) + abstract_self.SetAttribute(name, value) } // http://dom.spec.whatwg.org/#dom-element-setattributens