mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +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::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::window::Window;
|
||||
use servo_util::namespace::{Namespace, Null};
|
||||
use servo_util::namespace::Namespace;
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
#[deriving(Encodable)]
|
||||
|
@ -43,20 +43,9 @@ impl Attr {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn new(window: &JS<Window>, local_name: DOMString, value: DOMString) -> JS<Attr> {
|
||||
let name = local_name.clone();
|
||||
Attr::new_helper(window, local_name, value, name, Null, None)
|
||||
}
|
||||
|
||||
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> {
|
||||
pub fn new(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);
|
||||
reflect_dom_object(~attr, window, AttrBinding::Wrap)
|
||||
}
|
||||
|
|
|
@ -286,8 +286,8 @@ impl AttributeHandlers for JS<Element> {
|
|||
None => {
|
||||
let node: JS<Node> = NodeCast::from(self);
|
||||
let doc = node.get().owner_doc().get();
|
||||
let new_attr = Attr::new_ns(&doc.window, local_name.clone(), value.clone(),
|
||||
name, namespace.clone(), prefix);
|
||||
let new_attr = Attr::new(&doc.window, local_name.clone(), value.clone(),
|
||||
name, namespace.clone(), prefix);
|
||||
self.get_mut().attrs.push(new_attr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1372,10 +1372,10 @@ impl Node {
|
|||
copy_elem.namespace = node_elem.namespace.clone();
|
||||
for attr in node_elem.attrs.iter() {
|
||||
let attr = attr.get();
|
||||
copy_elem.attrs.push(Attr::new_ns(&document.get().window,
|
||||
attr.local_name.clone(), attr.value.clone(),
|
||||
attr.name.clone(), attr.namespace.clone(),
|
||||
attr.prefix.clone()));
|
||||
copy_elem.attrs.push(Attr::new(&document.get().window,
|
||||
attr.local_name.clone(), attr.value.clone(),
|
||||
attr.name.clone(), attr.namespace.clone(),
|
||||
attr.prefix.clone()));
|
||||
}
|
||||
},
|
||||
_ => ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue