Chromium Code Reviews| 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 $LIBRARYNAME; | 7 part of $LIBRARYNAME; |
| 8 | 8 |
| 9 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 9 $(ANNOTATIONS)$(CLASS_MODIFIERS)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 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 * Normally events should be created via their constructors, if available. | 26 * Normally events should be created via their constructors, if available. |
| 27 * | 27 * |
| 28 * var e = new Event.type('MouseEvent', 'mousedown', true, true); | 28 * var e = new Event.type('MouseEvent', 'mousedown', true, true); |
| 29 */ | 29 */ |
| 30 factory Event.eventType(String type, String name, {bool canBubble: true, | 30 factory Event.eventType(String type, String name, {bool canBubble: true, |
| 31 bool cancelable: true}) { | 31 bool cancelable: true}) { |
| 32 final Event e = document._createEvent(type); | 32 final Event e = document._createEvent(type); |
| 33 e._initEvent(name, canBubble, cancelable); | 33 e._initEvent(name, canBubble, cancelable); |
| 34 return e; | 34 return e; |
| 35 } | 35 } |
| 36 | |
| 37 /** The CSS selector involved with event delegation. */ | |
| 38 String _selector; | |
| 36 | 39 |
| 37 $CLASSNAME._private(); | 40 /** |
| 41 * A pointer to the element whose CSS selector matched within which an event | |
| 42 * was fired. If this Event was not associated with any Event delegation, | |
| 43 * then this value will be null. | |
|
blois
2013/10/09 23:12:57
Update comment for exception
| |
| 44 */ | |
| 45 Element matchingTarget() { | |
| 46 if (_selector == null) { | |
| 47 throw new UnsupportedError('Cannot call matchingTarget if this Event did' | |
| 48 ' not arise as a result of event delegation.'); | |
| 49 } | |
| 50 var currentTarget = this.currentTarget; | |
| 51 var target = this.target; | |
| 52 var matchedTarget; | |
| 53 while (matchedTarget == null && target != currentTarget && target != null) { | |
| 54 if (target.matches(_selector)) { | |
| 55 matchedTarget = target; | |
| 56 } | |
| 57 target = target.parent; | |
| 58 } | |
| 59 return matchedTarget; | |
| 60 } | |
| 38 $!MEMBERS | 61 $!MEMBERS |
| 39 } | 62 } |
| OLD | NEW |