| Index: sdk/lib/html/dartium/html_dartium.dart
|
| diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
|
| index 9281408de91893c0664253a8b8d3cfb90c48c315..9731b2cffcc0bea5c5cf190574537777000d3185 100644
|
| --- a/sdk/lib/html/dartium/html_dartium.dart
|
| +++ b/sdk/lib/html/dartium/html_dartium.dart
|
| @@ -11475,8 +11475,31 @@ class Event extends NativeFieldWrapperClass1 {
|
| e._initEvent(name, canBubble, cancelable);
|
| return e;
|
| }
|
| +
|
| + /** The CSS selector involved with event delegation. */
|
| + String _selector;
|
|
|
| - Event._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,
|
| + * accessing this value will throw an [UnsupportedError].
|
| + */
|
| + Element get 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;
|
| + }
|
|
|
| @DomName('Event.AT_TARGET')
|
| @DocsEditable()
|
| @@ -31151,8 +31174,11 @@ class _ElementEventStreamImpl<T extends Event> extends _EventStream<T>
|
| _ElementEventStreamImpl(target, eventType, useCapture) :
|
| super(target, eventType, useCapture);
|
|
|
| - Stream<T> matches(String selector) =>
|
| - this.where((event) => event.target.matchesWithAncestors(selector));
|
| + Stream<T> matches(String selector) => this.where(
|
| + (event) => event.target.matchesWithAncestors(selector)).map((e) {
|
| + e._selector = selector;
|
| + return e;
|
| + });
|
| }
|
|
|
| /**
|
| @@ -31173,8 +31199,11 @@ class _ElementListEventStreamImpl<T extends Event> extends Stream<T>
|
| _stream = _pool.stream;
|
| }
|
|
|
| - Stream<T> matches(String selector) =>
|
| - this.where((event) => event.target.matchesWithAncestors(selector));
|
| + Stream<T> matches(String selector) => this.where(
|
| + (event) => event.target.matchesWithAncestors(selector)).map((e) {
|
| + e._selector = selector;
|
| + return e;
|
| + });
|
|
|
| // Delegate all regular Stream behavor to our wrapped Stream.
|
| StreamSubscription<T> listen(void onData(T event),
|
|
|