OLD | NEW |
1 | 1 |
2 class NamedNodeMapJs extends DOMTypeJs implements NamedNodeMap native "*NamedNod
eMap" { | 2 class NamedNodeMapJs extends DOMTypeJs implements NamedNodeMap native "*NamedNod
eMap" { |
3 | 3 |
4 int get length() native "return this.length;"; | 4 int get length() native "return this.length;"; |
5 | 5 |
6 NodeJs operator[](int index) native "return this[index];"; | 6 NodeJs operator[](int index) native; |
7 | 7 |
8 void operator[]=(int index, NodeJs value) { | 8 void operator[]=(int index, NodeJs value) { |
9 throw new UnsupportedOperationException("Cannot assign element of immutable
List."); | 9 throw new UnsupportedOperationException("Cannot assign element of immutable
List."); |
10 } | 10 } |
11 // -- start List<Node> mixins. | |
12 // Node is the element type. | |
13 | |
14 // From Iterable<Node>: | |
15 | |
16 Iterator<Node> iterator() { | |
17 // Note: NodeLists are not fixed size. And most probably length shouldn't | |
18 // be cached in both iterator _and_ forEach method. For now caching it | |
19 // for consistency. | |
20 return new _FixedSizeListIterator<Node>(this); | |
21 } | |
22 | |
23 // From Collection<Node>: | |
24 | |
25 void add(Node value) { | |
26 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
27 } | |
28 | |
29 void addLast(Node value) { | |
30 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
31 } | |
32 | |
33 void addAll(Collection<Node> collection) { | |
34 throw new UnsupportedOperationException("Cannot add to immutable List."); | |
35 } | |
36 | |
37 void forEach(void f(Node element)) => _Collections.forEach(this, f); | |
38 | |
39 Collection map(f(Node element)) => _Collections.map(this, [], f); | |
40 | |
41 Collection<Node> filter(bool f(Node element)) => | |
42 _Collections.filter(this, <Node>[], f); | |
43 | |
44 bool every(bool f(Node element)) => _Collections.every(this, f); | |
45 | |
46 bool some(bool f(Node element)) => _Collections.some(this, f); | |
47 | |
48 bool isEmpty() => this.length == 0; | |
49 | |
50 // From List<Node>: | |
51 | |
52 void sort(int compare(Node a, Node b)) { | |
53 throw new UnsupportedOperationException("Cannot sort immutable List."); | |
54 } | |
55 | |
56 int indexOf(Node element, [int start = 0]) => | |
57 _Lists.indexOf(this, element, start, this.length); | |
58 | |
59 int lastIndexOf(Node element, [int start = 0]) => | |
60 _Lists.lastIndexOf(this, element, start); | |
61 | |
62 Node last() => this[length - 1]; | |
63 | |
64 // FIXME: implement thesee. | |
65 void setRange(int start, int length, List<Node> from, [int startFrom]) { | |
66 throw new UnsupportedOperationException("Cannot setRange on immutable List."
); | |
67 } | |
68 void removeRange(int start, int length) { | |
69 throw new UnsupportedOperationException("Cannot removeRange on immutable Lis
t."); | |
70 } | |
71 void insertRange(int start, int length, [Node initialValue]) { | |
72 throw new UnsupportedOperationException("Cannot insertRange on immutable Lis
t."); | |
73 } | |
74 List<Node> getRange(int start, int length) => | |
75 _Lists.getRange(this, start, length, <Node>[]); | |
76 | |
77 // -- end List<Node> mixins. | |
78 | 11 |
79 NodeJs getNamedItem(String name) native; | 12 NodeJs getNamedItem(String name) native; |
80 | 13 |
81 NodeJs getNamedItemNS(String namespaceURI, String localName) native; | 14 NodeJs getNamedItemNS(String namespaceURI, String localName) native; |
82 | 15 |
83 NodeJs item(int index) native; | 16 NodeJs item(int index) native; |
84 | 17 |
85 NodeJs removeNamedItem(String name) native; | 18 NodeJs removeNamedItem(String name) native; |
86 | 19 |
87 NodeJs removeNamedItemNS(String namespaceURI, String localName) native; | 20 NodeJs removeNamedItemNS(String namespaceURI, String localName) native; |
88 | 21 |
89 NodeJs setNamedItem(NodeJs node) native; | 22 NodeJs setNamedItem(NodeJs node) native; |
90 | 23 |
91 NodeJs setNamedItemNS(NodeJs node) native; | 24 NodeJs setNamedItemNS(NodeJs node) native; |
92 } | 25 } |
OLD | NEW |