From 77941dc996ccf938e7e9638b24a985a4816b9c25 Mon Sep 17 00:00:00 2001 From: lpy Date: Tue, 8 Apr 2014 17:06:17 +0800 Subject: [PATCH] Move Node.namespaceURI to Element.(fixes #2059) --- src/components/script/dom/element.rs | 5 +++++ src/components/script/dom/node.rs | 6 ------ src/components/script/dom/webidls/Element.webidl | 3 ++- src/components/script/dom/webidls/Node.webidl | 4 +--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs index 8299f516119..3caf5cca129 100644 --- a/src/components/script/dom/element.rs +++ b/src/components/script/dom/element.rs @@ -443,6 +443,11 @@ impl Element { } impl Element { + // http://dom.spec.whatwg.org/#dom-element-namespaceuri + pub fn NamespaceURI(&self) -> DOMString { + self.namespace.to_str().to_owned() + } + // http://dom.spec.whatwg.org/#dom-element-tagname pub fn TagName(&self) -> DOMString { self.tag_name.to_ascii_upper() diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs index 77ca388be9e..eb259c4641d 100644 --- a/src/components/script/dom/node.rs +++ b/src/components/script/dom/node.rs @@ -1733,12 +1733,6 @@ impl Node { false } - // http://dom.spec.whatwg.org/#dom-node-namespaceuri - pub fn GetNamespaceURI(&self, abstract_self: &JS) -> Option { - let element: Option> = ElementCast::to(abstract_self); - element.map(|element| element.get().namespace.to_str().to_owned()) - } - // http://dom.spec.whatwg.org/#dom-node-prefix pub fn GetPrefix(&self) -> Option { None diff --git a/src/components/script/dom/webidls/Element.webidl b/src/components/script/dom/webidls/Element.webidl index 2211fd5c887..aa0161204b0 100644 --- a/src/components/script/dom/webidls/Element.webidl +++ b/src/components/script/dom/webidls/Element.webidl @@ -18,10 +18,11 @@ interface Element : Node { We haven't moved these from Node to Element like the spec wants. [Throws] - readonly attribute DOMString? namespaceURI; readonly attribute DOMString? prefix; readonly attribute DOMString localName; */ + [Constant] + readonly attribute DOMString namespaceURI; // Not [Constant] because it depends on which document we're in [Pure] readonly attribute DOMString tagName; diff --git a/src/components/script/dom/webidls/Node.webidl b/src/components/script/dom/webidls/Node.webidl index 2a13d6ab381..39555e1e0d8 100644 --- a/src/components/script/dom/webidls/Node.webidl +++ b/src/components/script/dom/webidls/Node.webidl @@ -79,11 +79,9 @@ interface Node : EventTarget { // Mozilla-specific stuff // These have been moved to Element in the spec. - // If we move namespaceURI, prefix and localName to Element they should return + // If we move prefix and localName to Element they should return // a non-nullable type. [Constant] - readonly attribute DOMString? namespaceURI; - [Constant] readonly attribute DOMString? prefix; [Constant] readonly attribute DOMString? localName;