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 $CLASSNAME extends _ElementJs |
| 6 implements Document |
| 7 native "*HTMLHtmlElement" { |
| 8 $!MEMBERS |
| 9 |
| 10 // We execute query selectors off the traditional document rather than the |
| 11 // HTMLHtmlElement to make the result of query and queryAll less surprising. |
| 12 // Note: this means that document.query('html') will return the Document. |
| 13 _ElementJs query(String selectors) native "return this.parentNode.querySelecto
r(selectors);"; |
| 14 ElementList queryAll(String selectors) native "return this.parentNode.querySel
ectorAll(selectors);"; |
| 15 |
| 16 // TODO(jacobr): remove these methods and let them be generated automatically |
| 17 // once dart supports defining fields with the same name in an interface and |
| 18 // its parent interface. |
| 19 String get title() native "return this.parentNode.title;"; |
| 20 void set title(String value) native "this.parentNode.title = value;"; |
| 21 |
| 22 |
| 23 // For efficiency and simplicity, we always use the HtmlElement as the |
| 24 // Document but sometimes internally we need the real JS document object. |
| 25 _NodeJs get _jsDocument() native "return this.parentNode;"; |
| 26 |
| 27 // The document doesn't have a parent element. |
| 28 _ElementJs get parent() => null; |
| 29 } |
| 30 |
| 31 // This class should not be externally visible. If a user ever gets access to |
| 32 // a _SecretHtmlDocumentJs object that is a bug. This object is hidden by |
| 33 // adding checks to all methods that could an HTMLDocument. We believe that |
| 34 // list is limited to Event.target, and HTMLHtmlElement.parent. |
| 35 class _SecretHtmlDocumentJs extends _NodeJs implements Node |
| 36 native "*HTMLDocument" { |
| 37 _DocumentJs get _documentElement() native "return this.documentElement;"; |
| 38 } |
| 39 |
| 40 EventTarget _FixHtmlDocumentReference(EventTarget eventTarget) { |
| 41 if (eventTarget is _SecretHtmlDocumentJs) { |
| 42 _SecretHtmlDocumentJs secretDocument = eventTarget; |
| 43 return secretDocument._documentElement; |
| 44 } else { |
| 45 return eventTarget; |
| 46 } |
| 47 } |
OLD | NEW |