OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 class $CLASSNAME extends _ElementJs | 5 class $CLASSNAME extends _ElementImpl |
6 implements Document | 6 implements Document |
7 native "*HTMLHtmlElement" { | 7 native "*HTMLHtmlElement" { |
8 $!MEMBERS | 8 $!MEMBERS |
9 | 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 | 10 // 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 | 11 // once dart supports defining fields with the same name in an interface and |
18 // its parent interface. | 12 // its parent interface. |
19 String get title() native "return this.parentNode.title;"; | 13 String get title() native "return this.parentNode.title;"; |
20 void set title(String value) native "this.parentNode.title = value;"; | 14 void set title(String value) native "this.parentNode.title = value;"; |
21 | 15 |
22 | 16 |
23 // For efficiency and simplicity, we always use the HtmlElement as the | 17 // For efficiency and simplicity, we always use the HtmlElement as the |
24 // Document but sometimes internally we need the real JS document object. | 18 // Document but sometimes internally we need the real JS document object. |
25 _NodeJs get _jsDocument() native "return this.parentNode;"; | 19 _NodeImpl get _jsDocument() native "return this.parentNode;"; |
26 | 20 |
27 // The document doesn't have a parent element. | 21 // The document doesn't have a parent element. |
28 _ElementJs get parent() => null; | 22 _ElementImpl get parent() => null; |
29 } | 23 } |
30 | 24 |
31 // This class should not be externally visible. If a user ever gets access to | 25 // 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 | 26 // a _SecretHtmlDocumentImpl object that is a bug. This object is hidden by |
33 // adding checks to all methods that could an HTMLDocument. We believe that | 27 // adding checks to all methods that could an HTMLDocument. We believe that |
34 // list is limited to Event.target, and HTMLHtmlElement.parent. | 28 // list is limited to Event.target, and HTMLHtmlElement.parent. |
35 class _SecretHtmlDocumentJs extends _NodeJs implements Node | 29 class _SecretHtmlDocumentImpl extends _NodeImpl implements Node |
36 native "*HTMLDocument" { | 30 native "*HTMLDocument" { |
37 _DocumentJs get _documentElement() native "return this.documentElement;"; | 31 _DocumentImpl get _documentElement() native "return this.documentElement;"; |
38 } | 32 } |
39 | 33 |
40 EventTarget _FixHtmlDocumentReference(EventTarget eventTarget) { | 34 EventTarget _FixHtmlDocumentReference(EventTarget eventTarget) { |
41 if (eventTarget is _SecretHtmlDocumentJs) { | 35 if (eventTarget is _SecretHtmlDocumentImpl) { |
42 _SecretHtmlDocumentJs secretDocument = eventTarget; | 36 _SecretHtmlDocumentImpl secretDocument = eventTarget; |
43 return secretDocument._documentElement; | 37 return secretDocument._documentElement; |
44 } else { | 38 } else { |
45 return eventTarget; | 39 return eventTarget; |
46 } | 40 } |
47 } | 41 } |
OLD | NEW |