OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 class _NodeImpl extends _EventTargetImpl implements Node native "*Node" { |
| 6 _NodeListImpl get nodes() { |
| 7 final list = _childNodes; |
| 8 list._parent = this; |
| 9 return list; |
| 10 } |
| 11 |
| 12 void set nodes(Collection<Node> value) { |
| 13 // Copy list first since we don't want liveness during iteration. |
| 14 // TODO(jacobr): there is a better way to do this. |
| 15 List copy = new List.from(value); |
| 16 nodes.clear(); |
| 17 nodes.addAll(copy); |
| 18 } |
| 19 |
| 20 // TODO(jacobr): should we throw an exception if parent is already null? |
| 21 _NodeImpl remove() { |
| 22 if (this.parent != null) { |
| 23 this.parent._removeChild(this); |
| 24 } |
| 25 return this; |
| 26 } |
| 27 |
| 28 _NodeImpl replaceWith(Node otherNode) { |
| 29 try { |
| 30 this.parent._replaceChild(otherNode, this); |
| 31 } catch(var e) { |
| 32 |
| 33 }; |
| 34 return this; |
| 35 } |
| 36 |
| 37 |
| 38 static final int ATTRIBUTE_NODE = 2; |
| 39 |
| 40 static final int CDATA_SECTION_NODE = 4; |
| 41 |
| 42 static final int COMMENT_NODE = 8; |
| 43 |
| 44 static final int DOCUMENT_FRAGMENT_NODE = 11; |
| 45 |
| 46 static final int DOCUMENT_NODE = 9; |
| 47 |
| 48 static final int DOCUMENT_POSITION_CONTAINED_BY = 0x10; |
| 49 |
| 50 static final int DOCUMENT_POSITION_CONTAINS = 0x08; |
| 51 |
| 52 static final int DOCUMENT_POSITION_DISCONNECTED = 0x01; |
| 53 |
| 54 static final int DOCUMENT_POSITION_FOLLOWING = 0x04; |
| 55 |
| 56 static final int DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; |
| 57 |
| 58 static final int DOCUMENT_POSITION_PRECEDING = 0x02; |
| 59 |
| 60 static final int DOCUMENT_TYPE_NODE = 10; |
| 61 |
| 62 static final int ELEMENT_NODE = 1; |
| 63 |
| 64 static final int ENTITY_NODE = 6; |
| 65 |
| 66 static final int ENTITY_REFERENCE_NODE = 5; |
| 67 |
| 68 static final int NOTATION_NODE = 12; |
| 69 |
| 70 static final int PROCESSING_INSTRUCTION_NODE = 7; |
| 71 |
| 72 static final int TEXT_NODE = 3; |
| 73 |
| 74 _NamedNodeMapImpl get _attributes() native "return this.attributes;"; |
| 75 |
| 76 _NodeListImpl get _childNodes() native "return this.childNodes;"; |
| 77 |
| 78 _NodeImpl get nextNode() native "return this.nextSibling;"; |
| 79 |
| 80 _DocumentImpl get document() => _FixHtmlDocumentReference(_document); |
| 81 |
| 82 _EventTargetImpl get _document() native "return this.ownerDocument;"; |
| 83 |
| 84 _NodeImpl get parent() native "return this.parentNode;"; |
| 85 |
| 86 _NodeImpl get previousNode() native "return this.previousSibling;"; |
| 87 |
| 88 String get text() native "return this.textContent;"; |
| 89 |
| 90 void set text(String value) native "this.textContent = value;"; |
| 91 |
| 92 _NodeImpl _appendChild(_NodeImpl newChild) native "return this.appendChild(new
Child);"; |
| 93 |
| 94 _NodeImpl clone(bool deep) native "return this.cloneNode(deep);"; |
| 95 |
| 96 bool contains(_NodeImpl other) native; |
| 97 |
| 98 bool hasChildNodes() native; |
| 99 |
| 100 _NodeImpl insertBefore(_NodeImpl newChild, _NodeImpl refChild) native; |
| 101 |
| 102 _NodeImpl _removeChild(_NodeImpl oldChild) native "return this.removeChild(old
Child);"; |
| 103 |
| 104 _NodeImpl _replaceChild(_NodeImpl newChild, _NodeImpl oldChild) native "return
this.replaceChild(newChild, oldChild);"; |
| 105 |
| 106 } |
OLD | NEW |