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

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

Side-by-side diff isn't available for this file because of its large size.
Issue 22529004: Add includeAncestors to dartium matches call. (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 dfaa5ed2ebb253bfca5649e7232c16284c45782d..d68a8adc1d3ae1539abfb4cc8b10d7139f19b509 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -9316,6 +9316,25 @@ abstract class Element extends Node implements ParentNode, ChildNode native "Ele
/**
* Checks if this element matches the CSS selectors.
+ */
+ @Experimental()
+ bool _matches(String selectors) {
+ if (JS('bool', '!!#.matches', this)) {
+ return JS('bool', '#.matches(#)', this, selectors);
+ } else if (JS('bool', '!!#.webkitMatchesSelector', this)) {
+ return JS('bool', '#.webkitMatchesSelector(#)', this, selectors);
+ } else if (JS('bool', '!!#.mozMatchesSelector', this)) {
+ return JS('bool', '#.mozMatchesSelector(#)', this, selectors);
+ } else if (JS('bool', '!!#.msMatchesSelector', this)) {
+ return matches = JS('bool', '#.msMatchesSelector(#)', this, selectors);
+ } else {
+ throw new UnsupportedError("Not supported on this platform");
+ }
+ 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
@@ -9325,19 +9344,7 @@ abstract class Element extends Node implements ParentNode, ChildNode native "Ele
bool matches(String selectors, [includeAncestors = false]) {
var elem = this;
do {
- bool matches = false;
- if (JS('bool', '!!#.matches', elem)) {
- matches = JS('bool', '#.matches(#)', elem, selectors);
- } else if (JS('bool', '!!#.webkitMatchesSelector', elem)) {
- matches = JS('bool', '#.webkitMatchesSelector(#)', elem, selectors);
- } else if (JS('bool', '!!#.mozMatchesSelector', elem)) {
- matches = JS('bool', '#.mozMatchesSelector(#)', elem, selectors);
- } else if (JS('bool', '!!#.msMatchesSelector', elem)) {
- matches = JS('bool', '#.msMatchesSelector(#)', elem, selectors);
- } else {
- throw new UnsupportedError("Not supported on this platform");
- }
- if (matches) return true;
+ if (elem._matches(selectors)) return true;
elem = elem.parent;
} while(includeAncestors && elem != null);
return false;
« 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