| Index: tools/dom/templates/html/impl/impl_Element.darttemplate
|
| diff --git a/tools/dom/templates/html/impl/impl_Element.darttemplate b/tools/dom/templates/html/impl/impl_Element.darttemplate
|
| index e708395b059e5f71425f6c61f64e00fa077cba35..32fce298624f7e8a223e1eeec844be719d7d1fc8 100644
|
| --- a/tools/dom/templates/html/impl/impl_Element.darttemplate
|
| +++ b/tools/dom/templates/html/impl/impl_Element.darttemplate
|
| @@ -877,6 +877,27 @@ $if DART2JS
|
|
|
| /**
|
| * 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;
|
| + }
|
| +$else
|
| +$endif
|
| +
|
| + /**
|
| + * 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
|
| @@ -886,25 +907,11 @@ $if DART2JS
|
| 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;
|
| }
|
| -$else
|
| -$endif
|
|
|
| $if DART2JS
|
| @Creates('Null') // Set from Dart code; does not instantiate a native type.
|
|
|