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

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

Issue 22305005: Make includeAncestors match a separate method. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d68a8adc1d3ae1539abfb4cc8b10d7139f19b509..2cd82cc9022ff21c253d425e7337d9073133f268 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -9318,7 +9318,7 @@ abstract class Element extends Node implements ParentNode, ChildNode native "Ele
* Checks if this element matches the CSS selectors.
*/
@Experimental()
- bool _matches(String selectors) {
+ bool matches(String selectors) {
if (JS('bool', '!!#.matches', this)) {
return JS('bool', '#.matches(#)', this, selectors);
} else if (JS('bool', '!!#.webkitMatchesSelector', this)) {
@@ -9333,20 +9333,14 @@ abstract class Element extends Node implements ParentNode, ChildNode native "Ele
return false;
}
- /**
- * Checks if this element matches the CSS selectors.
- *
- * If `includeAncestors` is true, we examine all of this element's parent
- * elements and also return true if any of its parent elements matches
- * `selectors`.
- */
+ /** Checks if this element or any of its parents match the CSS selectors. */
@Experimental()
- bool matches(String selectors, [includeAncestors = false]) {
+ bool matchesWithAncestors(String selectors) {
var elem = this;
do {
- if (elem._matches(selectors)) return true;
+ if (elem.matches(selectors)) return true;
elem = elem.parent;
- } while(includeAncestors && elem != null);
+ } while(elem != null);
return false;
}
@@ -28817,7 +28811,7 @@ class _ElementEventStreamImpl<T extends Event> extends _EventStream<T>
super(target, eventType, useCapture);
Stream<T> matches(String selector) =>
- this.where((event) => event.target.matches(selector, true));
+ this.where((event) => event.target.matchesWithAncestors(selector));
}
/**
@@ -28839,7 +28833,7 @@ class _ElementListEventStreamImpl<T extends Event> extends Stream<T>
}
Stream<T> matches(String selector) =>
- this.where((event) => event.target.matches(selector, true));
+ this.where((event) => event.target.matchesWIthAncestors(selector));
// Delegate all regular Stream behavor to our wrapped Stream.
StreamSubscription<T> listen(void onData(T event),
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698