Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 26722002: Add "matchingTarget" function to Event, which is the Element that matched the CSS value selector. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 708bdb016ca2a9c401377247d8acbd598516f465..a6f71bceeb746e7329aa4dc9d7c5ee8cc2e772d9 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -11063,7 +11063,33 @@ class Event extends Interceptor native "Event" {
return e;
}
- Event._private();
+ /**
+ * Caches the pointer to the element that matches CSS selector involved in
+ * the event.
+ */
+ Element _cachedMatchingTarget;
+
+ /**
+ * 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.
+ */
+ Element matchingTarget() {
+ if (_cachedMatchingTarget == null) {
+ 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;
+ }
+ _cachedMatchingTarget = matchedTarget;
+ }
+ return _cachedMatchingTarget;
+ }
@DomName('Event.AT_TARGET')
@DocsEditable()
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | tools/dom/templates/html/impl/impl_Event.darttemplate » ('J')

Powered by Google App Engine
This is Rietveld 408576698