Title: [174336] trunk
Revision
174336
Author
[email protected]
Date
2014-10-05 19:08:53 -0700 (Sun, 05 Oct 2014)

Log Message

Add a deprecation warning for Element.webkitMatchesSelector
https://bugs.webkit.org/show_bug.cgi?id=137417

Patch by Benjamin Poulain <[email protected]> on 2014-10-05
Reviewed by Christophe Dumez.

Source/WebCore:

Many scripts have assumed that the unprefixed version of ElementwebkitMatchesSelector
would be Element.matchesSelector. Feature detection scripts too often test
for Element.matchesSelector instead of Element.matches before calling Element.webkitMatchesSelector.

This patch add a deprecation warning for Element.webkitMatchesSelector with the hope
that it will push the adoption of the unprefixed version.

* dom/Element.cpp:
(WebCore::Element::webkitMatchesSelector):
* dom/Element.h:
* dom/Element.idl:

LayoutTests:

* jquery/resources/src/sizzle/sizzle.js:
This is a great example of library that needs fixing. The old sizzle
we have in WebKit used "matchesSelector" instead of "matches".

* fast/dom/SelectorAPI/attrname-case-insensitive-expected.txt:
* fast/dom/SelectorAPI/attrname-case-sensitive-expected.txt:
* fast/dom/SelectorAPI/caseID-almost-strict-expected.txt:
* fast/dom/SelectorAPI/caseID-expected.txt:
* fast/dom/SelectorAPI/caseID-strict-expected.txt:
* fast/dom/SelectorAPI/caseTag-expected.txt:
* fast/dom/SelectorAPI/caseTagX-expected.txt:
* fast/dom/SelectorAPI/detached-element-expected.txt:
* fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt:
* fast/dom/SelectorAPI/undefined-null-stringify-expected.txt:
Update the test results due to the warning.

* fast/forms/radio/radio-live-validation-style-expected.txt:
* fast/forms/radio/radio-live-validation-style.html:
That duplicate I added back when I unprefixed Element.matches() is useless.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (174335 => 174336)


--- trunk/LayoutTests/ChangeLog	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/ChangeLog	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,30 @@
+2014-10-05  Benjamin Poulain  <[email protected]>
+
+        Add a deprecation warning for Element.webkitMatchesSelector
+        https://bugs.webkit.org/show_bug.cgi?id=137417
+
+        Reviewed by Christophe Dumez.
+
+        * jquery/resources/src/sizzle/sizzle.js:
+        This is a great example of library that needs fixing. The old sizzle
+        we have in WebKit used "matchesSelector" instead of "matches".
+
+        * fast/dom/SelectorAPI/attrname-case-insensitive-expected.txt:
+        * fast/dom/SelectorAPI/attrname-case-sensitive-expected.txt:
+        * fast/dom/SelectorAPI/caseID-almost-strict-expected.txt:
+        * fast/dom/SelectorAPI/caseID-expected.txt:
+        * fast/dom/SelectorAPI/caseID-strict-expected.txt:
+        * fast/dom/SelectorAPI/caseTag-expected.txt:
+        * fast/dom/SelectorAPI/caseTagX-expected.txt:
+        * fast/dom/SelectorAPI/detached-element-expected.txt:
+        * fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt:
+        * fast/dom/SelectorAPI/undefined-null-stringify-expected.txt:
+        Update the test results due to the warning.
+
+        * fast/forms/radio/radio-live-validation-style-expected.txt:
+        * fast/forms/radio/radio-live-validation-style.html:
+        That duplicate I added back when I unprefixed Element.matches() is useless.
+
 2014-10-05  Benjamin Poulain  <[email protected]>
 
         Element.matches()'s argument is not supposed to be optional

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/attrname-case-insensitive-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/dom/SelectorAPI/attrname-case-insensitive-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/attrname-case-insensitive-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,13 @@
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
 PASS document.querySelector('div[baR]') is document.getElementById('bar')
 PASS document.getElementById('bar').matches('div[baR]') is true
 PASS document.getElementById('bar').webkitMatchesSelector('div[baR]') is true

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/attrname-case-sensitive-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/dom/SelectorAPI/attrname-case-sensitive-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/attrname-case-sensitive-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,7 @@
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
 PASS document.querySelector('div[baR]') is document.getElementById('bar')
 PASS document.getElementById('bar').matches('div[baR]') is true
 PASS document.getElementById('bar').webkitMatchesSelector('div[baR]') is true

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/caseID-almost-strict-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/dom/SelectorAPI/caseID-almost-strict-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/caseID-almost-strict-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,7 @@
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
 PASS document.querySelector('#lower1').textContent is 'lower 1'
 PASS document.querySelector('#LOWER2') is null
 PASS document.querySelector('#UPPER1').textContent is 'UPPER 1'

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/caseID-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/dom/SelectorAPI/caseID-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/caseID-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,7 @@
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
 PASS document.querySelector('#lower1').textContent is 'lower 1'
 PASS document.querySelector('#LOWER2').textContent is 'lower 2'
 PASS document.querySelector('#UPPER1').textContent is 'UPPER 1'

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/caseID-strict-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/dom/SelectorAPI/caseID-strict-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/caseID-strict-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,7 @@
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
 PASS document.querySelector('#lower1').textContent is 'lower 1'
 PASS document.querySelector('#LOWER2') is null
 PASS document.querySelector('#UPPER1').textContent is 'UPPER 1'

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/caseTag-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/dom/SelectorAPI/caseTag-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/caseTag-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,5 @@
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
 PASS document.querySelector('div SPAN').textContent is 'lower'
 PASS document.querySelector('div p').textContent is 'UPPER'
 PASS document.getElementById('lower1').matches('div SPAN') is true

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/caseTagX-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/dom/SelectorAPI/caseTagX-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/caseTagX-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,4 @@
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
 PASS document.querySelector('div SPAN') is null
 PASS document.getElementById('lower1').matches('div SPAN') is false
 PASS document.getElementById('lower1').webkitMatchesSelector('div SPAN') is false

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/detached-element-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/dom/SelectorAPI/detached-element-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/detached-element-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,5 @@
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
 This tests that querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) work with elements that are not in a document yet.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/matches-null-undefined-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/dom/SelectorAPI/matches-null-undefined-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/matches-null-undefined-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,9 @@
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
 Test Element.matches() with no argument, null, and undefined.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,15 @@
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
 This tests that we throw a NAMESPACE_ERR when parsing a selector string for querySelector and querySelectorAll that contains a namespace.
 
 PASS: document.querySelector('bbb|pre') throws: Error: NamespaceError: DOM Exception 14

Modified: trunk/LayoutTests/fast/dom/SelectorAPI/undefined-null-stringify-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/dom/SelectorAPI/undefined-null-stringify-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/dom/SelectorAPI/undefined-null-stringify-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,5 @@
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
+CONSOLE MESSAGE: Element.webkitMatchesSelector is deprecated. Use Element.matches instead.
 This tests that the querySelector, querySelectorAll and matchesSelector (webkitMatchesSelector) correctly stringify null and undefined to "null" and "undefined".
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Modified: trunk/LayoutTests/fast/forms/radio/radio-live-validation-style-expected.txt (174335 => 174336)


--- trunk/LayoutTests/fast/forms/radio/radio-live-validation-style-expected.txt	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/forms/radio/radio-live-validation-style-expected.txt	2014-10-06 02:08:53 UTC (rev 174336)
@@ -8,8 +8,6 @@
 PASS parent.removeChild($("radio2")); backgroundOf($("radio1")) is invalidColor
 PASS $("radio1").remove(); radio2.matches(":valid") is false
 PASS radio2.remove(); radio2.matches(":valid") is true
-FAIL $("radio1").remove(); radio2.webkitMatchesSelector(":valid") should be false. Threw exception TypeError: null is not an object (evaluating '$("radio1").remove')
-PASS radio2.remove(); radio2.webkitMatchesSelector(":valid") is true
 
 Removing a checked radio button from a required radio button group by name attribute change:
 PASS $("radio2").name = "group2"; backgroundOf($("radio1")) is invalidColor

Modified: trunk/LayoutTests/fast/forms/radio/radio-live-validation-style.html (174335 => 174336)


--- trunk/LayoutTests/fast/forms/radio/radio-live-validation-style.html	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/fast/forms/radio/radio-live-validation-style.html	2014-10-06 02:08:53 UTC (rev 174336)
@@ -36,8 +36,6 @@
 var radio2 = $('radio2');
 shouldBeFalse('$("radio1").remove(); radio2.matches(":valid")');
 shouldBeTrue('radio2.remove(); radio2.matches(":valid")');
-shouldBeFalse('$("radio1").remove(); radio2.webkitMatchesSelector(":valid")');
-shouldBeTrue('radio2.remove(); radio2.webkitMatchesSelector(":valid")');
 debug('');
 
 debug('Removing a checked radio button from a required radio button group by name attribute change:');

Modified: trunk/LayoutTests/jquery/resources/src/sizzle/sizzle.js (174335 => 174336)


--- trunk/LayoutTests/jquery/resources/src/sizzle/sizzle.js	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/LayoutTests/jquery/resources/src/sizzle/sizzle.js	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1200,7 +1200,7 @@
 
 (function(){
 	var html = document.documentElement,
-		matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
+		matches = html.matches || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
 		pseudoWorks = false;
 
 	try {

Modified: trunk/Source/WebCore/ChangeLog (174335 => 174336)


--- trunk/Source/WebCore/ChangeLog	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/Source/WebCore/ChangeLog	2014-10-06 02:08:53 UTC (rev 174336)
@@ -1,3 +1,22 @@
+2014-10-05  Benjamin Poulain  <[email protected]>
+
+        Add a deprecation warning for Element.webkitMatchesSelector
+        https://bugs.webkit.org/show_bug.cgi?id=137417
+
+        Reviewed by Christophe Dumez.
+
+        Many scripts have assumed that the unprefixed version of ElementwebkitMatchesSelector
+        would be Element.matchesSelector. Feature detection scripts too often test
+        for Element.matchesSelector instead of Element.matches before calling Element.webkitMatchesSelector.
+
+        This patch add a deprecation warning for Element.webkitMatchesSelector with the hope
+        that it will push the adoption of the unprefixed version.
+
+        * dom/Element.cpp:
+        (WebCore::Element::webkitMatchesSelector):
+        * dom/Element.h:
+        * dom/Element.idl:
+
 2014-10-05  Benjamin Poulain  <[email protected]>
 
         Element.matches()'s argument is not supposed to be optional

Modified: trunk/Source/WebCore/dom/Element.cpp (174335 => 174336)


--- trunk/Source/WebCore/dom/Element.cpp	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/Source/WebCore/dom/Element.cpp	2014-10-06 02:08:53 UTC (rev 174336)
@@ -2329,6 +2329,12 @@
     return nullptr;
 }
 
+bool Element::webkitMatchesSelector(const String& selector, ExceptionCode& ec)
+{
+    document().addConsoleMessage(MessageSource::Other, MessageLevel::Warning, ASCIILiteral("Element.webkitMatchesSelector is deprecated. Use Element.matches instead."));
+    return matches(selector, ec);
+}
+
 bool Element::shouldAppearIndeterminate() const
 {
     return false;

Modified: trunk/Source/WebCore/dom/Element.h (174335 => 174336)


--- trunk/Source/WebCore/dom/Element.h	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/Source/WebCore/dom/Element.h	2014-10-06 02:08:53 UTC (rev 174336)
@@ -452,6 +452,7 @@
 
     virtual bool matchesReadWritePseudoClass() const;
     bool matches(const String& selectors, ExceptionCode&);
+    bool webkitMatchesSelector(const String& selectors, ExceptionCode&);
     Element* closest(const String& selectors, ExceptionCode&);
     virtual bool shouldAppearIndeterminate() const;
 

Modified: trunk/Source/WebCore/dom/Element.idl (174335 => 174336)


--- trunk/Source/WebCore/dom/Element.idl	2014-10-06 00:47:04 UTC (rev 174335)
+++ trunk/Source/WebCore/dom/Element.idl	2014-10-06 02:08:53 UTC (rev 174336)
@@ -121,8 +121,8 @@
     [RaisesException] NodeList querySelectorAll(DOMString selectors);
 
     [RaisesException] boolean matches(DOMString selectors);
+    [RaisesException] boolean webkitMatchesSelector(DOMString selectors);
     [RaisesException] Element closest(DOMString selectors);    
-    [ImplementedAs=matches, RaisesException] boolean webkitMatchesSelector(DOMString selectors);
 
     // ElementTraversal API
     readonly attribute Element firstElementChild;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to