mirror of
https://github.com/servo/servo.git
synced 2025-06-25 01:24:37 +01:00
Merge Attr::new_ns and Attr::new.
This commit is contained in:
parent
d665ad5a17
commit
ed18e4c948
3 changed files with 10 additions and 21 deletions
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::AttrBinding;
|
||||||
use dom::bindings::js::JS;
|
use dom::bindings::js::JS;
|
||||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use servo_util::namespace::{Namespace, Null};
|
use servo_util::namespace::Namespace;
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[deriving(Encodable)]
|
#[deriving(Encodable)]
|
||||||
|
@ -43,20 +43,9 @@ impl Attr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &JS<Window>, local_name: DOMString, value: DOMString) -> JS<Attr> {
|
pub fn new(window: &JS<Window>, local_name: DOMString, value: DOMString,
|
||||||
let name = local_name.clone();
|
name: DOMString, namespace: Namespace,
|
||||||
Attr::new_helper(window, local_name, value, name, Null, None)
|
prefix: Option<DOMString>) -> JS<Attr> {
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new_ns(window: &JS<Window>, local_name: DOMString, value: DOMString,
|
|
||||||
name: DOMString, namespace: Namespace,
|
|
||||||
prefix: Option<DOMString>) -> JS<Attr> {
|
|
||||||
Attr::new_helper(window, local_name, value, name, namespace, prefix)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new_helper(window: &JS<Window>, local_name: DOMString, value: DOMString,
|
|
||||||
name: DOMString, namespace: Namespace,
|
|
||||||
prefix: Option<DOMString>) -> JS<Attr> {
|
|
||||||
let attr = Attr::new_inherited(local_name, value, name, namespace, prefix);
|
let attr = Attr::new_inherited(local_name, value, name, namespace, prefix);
|
||||||
reflect_dom_object(~attr, window, AttrBinding::Wrap)
|
reflect_dom_object(~attr, window, AttrBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,8 +286,8 @@ impl AttributeHandlers for JS<Element> {
|
||||||
None => {
|
None => {
|
||||||
let node: JS<Node> = NodeCast::from(self);
|
let node: JS<Node> = NodeCast::from(self);
|
||||||
let doc = node.get().owner_doc().get();
|
let doc = node.get().owner_doc().get();
|
||||||
let new_attr = Attr::new_ns(&doc.window, local_name.clone(), value.clone(),
|
let new_attr = Attr::new(&doc.window, local_name.clone(), value.clone(),
|
||||||
name, namespace.clone(), prefix);
|
name, namespace.clone(), prefix);
|
||||||
self.get_mut().attrs.push(new_attr);
|
self.get_mut().attrs.push(new_attr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1372,10 +1372,10 @@ impl Node {
|
||||||
copy_elem.namespace = node_elem.namespace.clone();
|
copy_elem.namespace = node_elem.namespace.clone();
|
||||||
for attr in node_elem.attrs.iter() {
|
for attr in node_elem.attrs.iter() {
|
||||||
let attr = attr.get();
|
let attr = attr.get();
|
||||||
copy_elem.attrs.push(Attr::new_ns(&document.get().window,
|
copy_elem.attrs.push(Attr::new(&document.get().window,
|
||||||
attr.local_name.clone(), attr.value.clone(),
|
attr.local_name.clone(), attr.value.clone(),
|
||||||
attr.name.clone(), attr.namespace.clone(),
|
attr.name.clone(), attr.namespace.clone(),
|
||||||
attr.prefix.clone()));
|
attr.prefix.clone()));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue