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 class JsIndexer { | |
23 const JsIndexer(); | |
24 } | |
25 | |
22 external Document get document; | 26 external Document get document; |
23 | 27 |
24 @JsName(name: 'Document') | 28 @JsName(name: 'Document') |
25 abstract class Document { | 29 abstract class Document { |
26 Element querySelector(String selector); | 30 Element querySelector(String selector); |
27 } | 31 } |
28 | 32 |
29 @JsName(name: 'Element') | 33 @JsName(name: 'Element') |
30 abstract class Element { | 34 abstract class Element { |
31 void addEventListener(String type, EventListener callback, [bool capture]); | 35 void addEventListener(String type, EventListener callback, [bool capture]); |
32 String textContent; | 36 String textContent; |
37 NodeList get childNodes; | |
38 } | |
39 | |
40 @JsName() | |
41 class Node {} | |
42 | |
43 @JsName() | |
44 @JsIndexer() | |
Jacob
2015/05/20 19:55:21
Seems a bit strange to have this annotation on the
Jennifer Messerly
2015/05/20 20:13:30
Hah, yeah, I wanted it that way too :). But we can
Jennifer Messerly
2015/06/01 17:36:58
Doh, I misunderstood your question.
Restating the
| |
45 class NodeList { | |
46 external NodeList(); | |
47 external num get length; | |
48 external set length(num _); | |
49 external Node item(num index); | |
50 | |
51 external Node operator [](num index); | |
52 external void operator []=(num index, Node); | |
33 } | 53 } |
34 | 54 |
35 typedef void EventListener(Event e); | 55 typedef void EventListener(Event e); |
36 | 56 |
57 @JsName() | |
37 abstract class Event {} | 58 abstract class Event {} |
38 | 59 |
39 @JsName(name: 'HTMLInputElement') | 60 @JsName(name: 'HTMLInputElement') |
40 abstract class InputElement extends Element { | 61 abstract class InputElement extends Element { |
41 String value; | 62 String value; |
42 } | 63 } |
43 | 64 |
44 @JsName(name: 'HTMLCanvasElement') | 65 @JsName(name: 'HTMLCanvasElement') |
45 abstract class CanvasElement extends Element { | 66 abstract class CanvasElement extends Element { |
46 RenderingContext getContext(String contextId); | 67 RenderingContext getContext(String contextId); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 abstract class TextMetrics { | 203 abstract class TextMetrics { |
183 num get width; | 204 num get width; |
184 } | 205 } |
185 | 206 |
186 @JsName() | 207 @JsName() |
187 abstract class ImageData { | 208 abstract class ImageData { |
188 int get width; | 209 int get width; |
189 int get height; | 210 int get height; |
190 // TODO: readonly Uint8ClampedArray data; | 211 // TODO: readonly Uint8ClampedArray data; |
191 } | 212 } |
OLD | NEW |