OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 @JsName(name: 'window') | 5 @JsName(name: 'window') |
6 library dom; | 6 library dom; |
7 | 7 |
8 | 8 |
9 class JsName { | 9 class JsName { |
10 /// The JavaScript name. | 10 /// The JavaScript name. |
11 /// Used for classes and libraries. | 11 /// Used for classes and libraries. |
12 /// Note that this could be an expression, e.g. `lib.TypeName` in JS, but it | 12 /// Note that this could be an expression, e.g. `lib.TypeName` in JS, but it |
13 /// should be kept simple, as it will be generated directly into the code. | 13 /// should be kept simple, as it will be generated directly into the code. |
14 final String name; | 14 final String name; |
15 const JsName({this.name}); | 15 const JsName({this.name}); |
16 } | 16 } |
17 class Overload { | 17 class Overload { |
18 const Overload(); | 18 const Overload(); |
19 } | 19 } |
20 const overload = const Overload(); | 20 const overload = const Overload(); |
21 | 21 |
22 external Document get document; | 22 external Document get document; |
23 | 23 |
24 @JsName(name: 'Document') | 24 @JsName(name: 'Document') |
25 abstract class Document { | 25 abstract class Document { |
| 26 Element createElement(String name); |
26 Element querySelector(String selector); | 27 Element querySelector(String selector); |
27 } | 28 } |
28 | 29 |
29 @JsName(name: 'Element') | 30 @JsName(name: 'Element') |
30 abstract class Element { | 31 abstract class Element { |
31 void addEventListener(String type, EventListener callback, [bool capture]); | 32 void addEventListener(String type, EventListener callback, [bool capture]); |
32 String textContent; | 33 String textContent; |
| 34 NodeList get childNodes; |
| 35 } |
| 36 |
| 37 @JsName() |
| 38 class Node {} |
| 39 |
| 40 @JsName() |
| 41 class NodeList { |
| 42 external NodeList(); |
| 43 external num get length; |
| 44 external set length(num _); |
| 45 external Node item(num index); |
| 46 |
| 47 external Node operator [](num index); |
| 48 external void operator []=(num index, Node); |
33 } | 49 } |
34 | 50 |
35 typedef void EventListener(Event e); | 51 typedef void EventListener(Event e); |
36 | 52 |
| 53 @JsName() |
37 abstract class Event {} | 54 abstract class Event {} |
38 | 55 |
39 @JsName(name: 'HTMLInputElement') | 56 @JsName(name: 'HTMLInputElement') |
40 abstract class InputElement extends Element { | 57 abstract class InputElement extends Element { |
41 String value; | 58 String value; |
42 } | 59 } |
43 | 60 |
44 @JsName(name: 'HTMLCanvasElement') | 61 @JsName(name: 'HTMLCanvasElement') |
45 abstract class CanvasElement extends Element { | 62 abstract class CanvasElement extends Element { |
46 RenderingContext getContext(String contextId); | 63 RenderingContext getContext(String contextId); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 abstract class TextMetrics { | 199 abstract class TextMetrics { |
183 num get width; | 200 num get width; |
184 } | 201 } |
185 | 202 |
186 @JsName() | 203 @JsName() |
187 abstract class ImageData { | 204 abstract class ImageData { |
188 int get width; | 205 int get width; |
189 int get height; | 206 int get height; |
190 // TODO: readonly Uint8ClampedArray data; | 207 // TODO: readonly Uint8ClampedArray data; |
191 } | 208 } |
OLD | NEW |