mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
Move SetAttribute onto JS<Element>.
This commit is contained in:
parent
3347c3ef80
commit
b19165e9e1
1 changed files with 14 additions and 8 deletions
|
@ -198,6 +198,7 @@ pub trait AttributeHandlers {
|
|||
fn do_set_attribute(&mut self, local_name: DOMString, value: DOMString,
|
||||
name: DOMString, namespace: Namespace,
|
||||
prefix: Option<DOMString>, cb: |&JS<Attr>| -> 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<Element> {
|
|||
}
|
||||
}
|
||||
|
||||
// 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<Node> = 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<Element>,
|
||||
pub fn SetAttribute(&self, abstract_self: &mut JS<Element>,
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue