Skip to content

Commit

Permalink
Rename AttrList to NamedNodeMap
Browse files Browse the repository at this point in the history
This fixes issue #3135
  • Loading branch information
Aaron1011 committed Aug 29, 2014
1 parent db05417 commit 3a56a69
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/components/script/dom/element.rs
Expand Up @@ -6,7 +6,7 @@

use dom::attr::{Attr, ReplacedAttr, FirstSetAttr, AttrHelpersForLayout};
use dom::attr::{AttrValue, StringAttrValue, UIntAttrValue, AtomAttrValue};
use dom::attrlist::AttrList;
use dom::namednodemap::NamedNodeMap;
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
use dom::bindings::codegen::Bindings::ElementBinding;
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
Expand Down Expand Up @@ -49,7 +49,7 @@ pub struct Element {
pub prefix: Option<DOMString>,
pub attrs: RefCell<Vec<JS<Attr>>>,
pub style_attribute: Traceable<RefCell<Option<style::PropertyDeclarationBlock>>>,
pub attr_list: Cell<Option<JS<AttrList>>>,
pub attr_list: Cell<Option<JS<NamedNodeMap>>>,
class_list: Cell<Option<JS<DOMTokenList>>>,
}

Expand Down Expand Up @@ -535,7 +535,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
}

// http://dom.spec.whatwg.org/#dom-element-attributes
fn Attributes(&self) -> Temporary<AttrList> {
fn Attributes(&self) -> Temporary<NamedNodeMap> {
match self.attr_list.get() {
None => (),
Some(ref list) => return Temporary::new(list.clone()),
Expand All @@ -546,7 +546,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
node.owner_doc().root()
};
let window = doc.deref().window.root();
let list = AttrList::new(&*window, self);
let list = NamedNodeMap::new(&*window, self);
self.attr_list.assign(Some(list));
Temporary::new(self.attr_list.get().get_ref().clone())
}
Expand Down
Expand Up @@ -3,35 +3,35 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use dom::attr::Attr;
use dom::bindings::codegen::Bindings::AttrListBinding;
use dom::bindings::codegen::Bindings::AttrListBinding::AttrListMethods;
use dom::bindings::codegen::Bindings::NamedNodeMapBinding;
use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
use dom::bindings::global::Window;
use dom::bindings::js::{JS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::element::Element;
use dom::window::Window;

#[deriving(Encodable)]
pub struct AttrList {
pub struct NamedNodeMap {
reflector_: Reflector,
owner: JS<Element>,
}

impl AttrList {
pub fn new_inherited(elem: &JSRef<Element>) -> AttrList {
AttrList {
impl NamedNodeMap {
pub fn new_inherited(elem: &JSRef<Element>) -> NamedNodeMap {
NamedNodeMap {
reflector_: Reflector::new(),
owner: JS::from_rooted(elem),
}
}

pub fn new(window: &JSRef<Window>, elem: &JSRef<Element>) -> Temporary<AttrList> {
reflect_dom_object(box AttrList::new_inherited(elem),
&Window(*window), AttrListBinding::Wrap)
pub fn new(window: &JSRef<Window>, elem: &JSRef<Element>) -> Temporary<NamedNodeMap> {
reflect_dom_object(box NamedNodeMap::new_inherited(elem),
&Window(*window), NamedNodeMapBinding::Wrap)
}
}

impl<'a> AttrListMethods for JSRef<'a, AttrList> {
impl<'a> NamedNodeMapMethods for JSRef<'a, NamedNodeMap> {
fn Length(&self) -> u32 {
self.owner.root().attrs.borrow().len() as u32
}
Expand All @@ -47,7 +47,7 @@ impl<'a> AttrListMethods for JSRef<'a, AttrList> {
}
}

impl Reflectable for AttrList {
impl Reflectable for NamedNodeMap {
fn reflector<'a>(&'a self) -> &'a Reflector {
&self.reflector_
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/script/dom/webidls/Element.webidl
Expand Up @@ -32,7 +32,7 @@ interface Element : Node {
readonly attribute DOMTokenList classList;

[Constant]
readonly attribute AttrList attributes;
readonly attribute NamedNodeMap attributes;
DOMString? getAttribute(DOMString name);
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
[Throws]
Expand Down
Expand Up @@ -2,8 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

[NoInterfaceObject]
interface AttrList {
interface NamedNodeMap {
readonly attribute unsigned long length;
getter Attr? item(unsigned long index);
};
2 changes: 1 addition & 1 deletion src/components/script/script.rs
Expand Up @@ -76,7 +76,6 @@ pub mod dom {
pub mod macros;

pub mod attr;
pub mod attrlist;
pub mod blob;
pub mod browsercontext;
pub mod canvasrenderingcontext2d;
Expand Down Expand Up @@ -173,6 +172,7 @@ pub mod dom {
pub mod location;
pub mod messageevent;
pub mod mouseevent;
pub mod namednodemap;
pub mod navigator;
pub mod node;
pub mod nodeiterator;
Expand Down
1 change: 1 addition & 0 deletions src/test/content/test_interfaces.html
Expand Up @@ -144,6 +144,7 @@
"Location",
"MessageEvent",
"MouseEvent",
"NamedNodeMap",
"Navigator",
"Node",
"NodeIterator",
Expand Down
5 changes: 5 additions & 0 deletions src/test/wpt/metadata/dom/historical.html.ini
@@ -0,0 +1,5 @@
[historical.html]
type: testharness
[Historical DOM features must be removed: NamedNodeMap]
expected: FAIL

0 comments on commit 3a56a69

Please sign in to comment.