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 // WARNING: Do not edit - generated code. | 5 // WARNING: Do not edit - generated code. |
6 | 6 |
7 part of html; | 7 part of html; |
8 | 8 |
9 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 9 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
10 // In JS, canBubble and cancelable are technically required parameters to | 10 // In JS, canBubble and cancelable are technically required parameters to |
11 // init*Event. In practice, though, if they aren't provided they simply | 11 // init*Event. In practice, though, if they aren't provided they simply |
12 // default to false (since that's Boolean(undefined)). | 12 // default to false (since that's Boolean(undefined)). |
13 // | 13 // |
14 // Contrary to JS, we default canBubble and cancelable to true, since that's | 14 // Contrary to JS, we default canBubble and cancelable to true, since that's |
15 // what people want most of the time anyway. | 15 // what people want most of the time anyway. |
16 factory $CLASSNAME(String type, | 16 factory $CLASSNAME(String type, |
17 [bool canBubble = true, bool cancelable = true]) { | 17 {bool canBubble: true, bool cancelable: true}) { |
18 return new Event.eventType('Event', type, canBubble, cancelable); | 18 return new Event.eventType('Event', type, canBubble: canBubble, |
| 19 cancelable: canBubble); |
19 } | 20 } |
20 | 21 |
21 /** | 22 /** |
22 * Creates a new Event object of the specified type. | 23 * Creates a new Event object of the specified type. |
23 * | 24 * |
24 * This is analogous to document.createEvent. | 25 * This is analogous to document.createEvent. |
25 * Normally events should be created via their constructors, if available. | 26 * Normally events should be created via their constructors, if available. |
26 * | 27 * |
27 * var e = new Event.type('MouseEvent', 'mousedown', true, true); | 28 * var e = new Event.type('MouseEvent', 'mousedown', true, true); |
28 */ | 29 */ |
29 factory Event.eventType(String type, String name, [bool canBubble = true, | 30 factory Event.eventType(String type, String name, {bool canBubble: true, |
30 bool cancelable = true]) { | 31 bool cancelable: true}) { |
31 final Event e = document.$dom_createEvent(type); | 32 final Event e = document.$dom_createEvent(type); |
32 e.$dom_initEvent(name, canBubble, cancelable); | 33 e.$dom_initEvent(name, canBubble, cancelable); |
33 return e; | 34 return e; |
34 } | 35 } |
35 $!MEMBERS | 36 $!MEMBERS |
36 | 37 |
37 /** | 38 /** |
38 * Checks to see if the event class is supported by the current platform. | 39 * Checks to see if the event class is supported by the current platform. |
39 */ | 40 */ |
40 static bool _isTypeSupported(String eventType) { | 41 static bool _isTypeSupported(String eventType) { |
41 // Browsers throw for unsupported event names. | 42 // Browsers throw for unsupported event names. |
42 try { | 43 try { |
43 var e = document.$dom_createEvent(eventType); | 44 var e = document.$dom_createEvent(eventType); |
44 return e is Event; | 45 return e is Event; |
45 } catch (_) { } | 46 } catch (_) { } |
46 return false; | 47 return false; |
47 } | 48 } |
48 } | 49 } |
OLD | NEW |