Chromium Code Reviews| Index: tools/dom/templates/html/impl/impl_Event.darttemplate |
| diff --git a/tools/dom/templates/html/impl/impl_Event.darttemplate b/tools/dom/templates/html/impl/impl_Event.darttemplate |
| index a3fc47f660dd5faa429cd19a30bde06f4fc51673..8562920dc0c7ddaf84bcede6247275e0aa874230 100644 |
| --- a/tools/dom/templates/html/impl/impl_Event.darttemplate |
| +++ b/tools/dom/templates/html/impl/impl_Event.darttemplate |
| @@ -33,7 +33,30 @@ $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| e._initEvent(name, canBubble, cancelable); |
| return e; |
| } |
| + |
| + /** The CSS selector involved with event delegation. */ |
| + String _selector; |
| - $CLASSNAME._private(); |
| + /** |
| + * A pointer to the element whose CSS selector matched within which an event |
| + * was fired. If this Event was not associated with any Event delegation, |
| + * then this value will be null. |
|
blois
2013/10/09 23:12:57
Update comment for exception
|
| + */ |
| + Element matchingTarget() { |
| + if (_selector == null) { |
| + throw new UnsupportedError('Cannot call matchingTarget if this Event did' |
| + ' not arise as a result of event delegation.'); |
| + } |
| + var currentTarget = this.currentTarget; |
| + var target = this.target; |
| + var matchedTarget; |
| + while (matchedTarget == null && target != currentTarget && target != null) { |
| + if (target.matches(_selector)) { |
| + matchedTarget = target; |
| + } |
| + target = target.parent; |
| + } |
| + return matchedTarget; |
| + } |
| $!MEMBERS |
| } |