aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/script')
-rw-r--r--src/components/script/dom/document.rs4
-rw-r--r--src/components/script/dom/element.rs22
-rw-r--r--src/components/script/dom/htmlelement.rs2
-rw-r--r--src/components/script/dom/node.rs10
-rw-r--r--src/components/script/dom/webidls/Element.webidl7
-rw-r--r--src/components/script/dom/webidls/Node.webidl9
6 files changed, 23 insertions, 31 deletions
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs
index 7427b809086..95298eef358 100644
--- a/src/components/script/dom/document.rs
+++ b/src/components/script/dom/document.rs
@@ -269,7 +269,7 @@ impl Document {
}
let (prefix_from_qname, local_name_from_qname) = get_attribute_parts(qualified_name);
- match (&ns, prefix_from_qname, local_name_from_qname.as_slice()) {
+ match (&ns, prefix_from_qname.clone(), local_name_from_qname.as_slice()) {
// throw if prefix is not null and namespace is null
(&namespace::Null, Some(_), _) => {
debug!("Namespace can't be null with a non-null prefix");
@@ -293,7 +293,7 @@ impl Document {
if ns == namespace::HTML {
Ok(build_element_from_tag(local_name_from_qname, abstract_self))
} else {
- Ok(Element::new(local_name_from_qname, ns, abstract_self))
+ Ok(Element::new(local_name_from_qname, ns, prefix_from_qname, abstract_self))
}
}
diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs
index 3abe8de8edb..ace3f68bccc 100644
--- a/src/components/script/dom/element.rs
+++ b/src/components/script/dom/element.rs
@@ -36,6 +36,7 @@ pub struct Element {
node: Node,
tag_name: DOMString, // TODO: This should be an atom, not a DOMString.
namespace: Namespace,
+ prefix: Option<DOMString>,
attrs: ~[JS<Attr>],
style_attribute: Option<style::PropertyDeclarationBlock>,
attr_list: Option<JS<AttrList>>
@@ -139,19 +140,20 @@ pub enum ElementTypeId {
//
impl Element {
- pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, namespace: Namespace, document: JS<Document>) -> Element {
+ pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: JS<Document>) -> Element {
Element {
node: Node::new_inherited(ElementNodeTypeId(type_id), document),
tag_name: tag_name,
namespace: namespace,
+ prefix: prefix,
attrs: ~[],
attr_list: None,
style_attribute: None,
}
}
- pub fn new(tag_name: DOMString, namespace: Namespace, document: &JS<Document>) -> JS<Element> {
- let element = Element::new_inherited(ElementTypeId, tag_name, namespace, document.clone());
+ pub fn new(tag_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: &JS<Document>) -> JS<Element> {
+ let element = Element::new_inherited(ElementTypeId, tag_name, namespace, prefix, document.clone());
Node::reflect_node(~element, document, ElementBinding::Wrap)
}
@@ -455,9 +457,21 @@ impl Element {
self.namespace.to_str().to_owned()
}
+ // http://dom.spec.whatwg.org/#dom-element-prefix
+ pub fn GetPrefix(&self) -> Option<DOMString> {
+ self.prefix.clone()
+ }
+
// http://dom.spec.whatwg.org/#dom-element-tagname
pub fn TagName(&self) -> DOMString {
- self.tag_name.to_ascii_upper()
+ match self.prefix {
+ None => {
+ self.tag_name.to_ascii_upper()
+ }
+ Some(ref prefix_str) => {
+ (*prefix_str + ":" + self.tag_name).to_ascii_upper()
+ }
+ }
}
// http://dom.spec.whatwg.org/#dom-element-id
diff --git a/src/components/script/dom/htmlelement.rs b/src/components/script/dom/htmlelement.rs
index 30f3e7b552c..b3442304fcc 100644
--- a/src/components/script/dom/htmlelement.rs
+++ b/src/components/script/dom/htmlelement.rs
@@ -35,7 +35,7 @@ impl HTMLElementDerived for EventTarget {
impl HTMLElement {
pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: JS<Document>) -> HTMLElement {
HTMLElement {
- element: Element::new_inherited(type_id, tag_name, namespace::HTML, document)
+ element: Element::new_inherited(type_id, tag_name, namespace::HTML, None, document)
}
}
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs
index fd55732da82..86137fef714 100644
--- a/src/components/script/dom/node.rs
+++ b/src/components/script/dom/node.rs
@@ -1731,16 +1731,6 @@ impl Node {
false
}
- // http://dom.spec.whatwg.org/#dom-node-prefix
- pub fn GetPrefix(&self) -> Option<DOMString> {
- None
- }
-
- // http://dom.spec.whatwg.org/#dom-node-localname
- pub fn GetLocalName(&self) -> Option<DOMString> {
- None
- }
-
//
// Low-level pointer stitching
//
diff --git a/src/components/script/dom/webidls/Element.webidl b/src/components/script/dom/webidls/Element.webidl
index aa0161204b0..1874bfbe651 100644
--- a/src/components/script/dom/webidls/Element.webidl
+++ b/src/components/script/dom/webidls/Element.webidl
@@ -14,13 +14,10 @@
*/
interface Element : Node {
-/*
- We haven't moved these from Node to Element like the spec wants.
- [Throws]
readonly attribute DOMString? prefix;
- readonly attribute DOMString localName;
-*/
+ // readonly attribute DOMString localName;
+
[Constant]
readonly attribute DOMString namespaceURI;
// Not [Constant] because it depends on which document we're in
diff --git a/src/components/script/dom/webidls/Node.webidl b/src/components/script/dom/webidls/Node.webidl
index 39555e1e0d8..acec121ccd2 100644
--- a/src/components/script/dom/webidls/Node.webidl
+++ b/src/components/script/dom/webidls/Node.webidl
@@ -76,13 +76,4 @@ interface Node : EventTarget {
Node replaceChild(Node node, Node child);
[Throws]
Node removeChild(Node child);
-
- // Mozilla-specific stuff
- // These have been moved to Element in the spec.
- // If we move prefix and localName to Element they should return
- // a non-nullable type.
- [Constant]
- readonly attribute DOMString? prefix;
- [Constant]
- readonly attribute DOMString? localName;
};