Title: [234803] trunk
Revision
234803
Author
[email protected]
Date
2018-08-13 09:39:14 -0700 (Mon, 13 Aug 2018)

Log Message

Followup (r234683): Element::getAttribute() should return the first non-null attribute value
https://bugs.webkit.org/show_bug.cgi?id=188419

Patch by Said Abou-Hallawa <[email protected]> on 2018-08-13
Reviewed by Darin Adler.

Source/WebCore:

Element::getAttribute() should return the first non-null attribute value
since an empty string is a legitimate attribute value.

Test: svg/custom/href-svg-namespace-empty.html

* dom/Element.h:
(WebCore::Element::getAttribute const):

LayoutTests:

* svg/custom/href-svg-namespace-empty-expected.txt: Added.
* svg/custom/href-svg-namespace-empty.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (234802 => 234803)


--- trunk/LayoutTests/ChangeLog	2018-08-13 16:21:46 UTC (rev 234802)
+++ trunk/LayoutTests/ChangeLog	2018-08-13 16:39:14 UTC (rev 234803)
@@ -1,3 +1,13 @@
+2018-08-13  Said Abou-Hallawa  <[email protected]>
+
+        Followup (r234683): Element::getAttribute() should return the first non-null attribute value
+        https://bugs.webkit.org/show_bug.cgi?id=188419
+
+        Reviewed by Darin Adler.
+
+        * svg/custom/href-svg-namespace-empty-expected.txt: Added.
+        * svg/custom/href-svg-namespace-empty.html: Added.
+
 2018-08-13  Zalan Bujtas  <[email protected]>
 
         [LFC][Floating] Add basic clearance support

Added: trunk/LayoutTests/svg/custom/href-svg-namespace-empty-expected.txt (0 => 234803)


--- trunk/LayoutTests/svg/custom/href-svg-namespace-empty-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/href-svg-namespace-empty-expected.txt	2018-08-13 16:39:14 UTC (rev 234803)
@@ -0,0 +1,19 @@
+Test the possible cases of the svg href attribute value: null string, empty string and non-empty string.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.element.getAttributeNS('http://www.w3.org/1999/xlink', 'href') is null
+PASS window.element.getAttribute('href') is null
+PASS window.element.getAttributeNS('http://www.w3.org/1999/xlink', 'href') is "www.webkit.org"
+PASS window.element.getAttribute('href') is "www.webkit.org"
+PASS window.element.getAttributeNS('http://www.w3.org/1999/xlink', 'href') is ""
+PASS window.element.getAttribute('href') is ""
+PASS window.element.getAttributeNS('http://www.w3.org/1999/xlink', 'href') is "www.build.webkit.org"
+PASS window.element.getAttribute('href') is "www.build.webkit.org"
+PASS window.element.getAttributeNS('http://www.w3.org/1999/xlink', 'href') is ""
+PASS window.element.getAttribute('href') is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/svg/custom/href-svg-namespace-empty.html (0 => 234803)


--- trunk/LayoutTests/svg/custom/href-svg-namespace-empty.html	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/href-svg-namespace-empty.html	2018-08-13 16:39:14 UTC (rev 234803)
@@ -0,0 +1,29 @@
+<head>
+    <script src=""
+</head>
+<body>
+    <script>
+        description("Test the possible cases of the svg href attribute value: null string, empty string and non-empty string.");
+
+        window.element = document.createElementNS("http://www.w3.org/2000/svg", "a");
+        shouldBeNull("window.element.getAttributeNS('http://www.w3.org/1999/xlink', 'href')");
+        shouldBeNull("window.element.getAttribute('href')");
+
+        window.element.setAttributeNS("http://www.w3.org/1999/xlink", "href", "www.webkit.org");
+        shouldBeEqualToString("window.element.getAttributeNS('http://www.w3.org/1999/xlink', 'href')", "www.webkit.org");
+        shouldBeEqualToString("window.element.getAttribute('href')",  "www.webkit.org");
+
+        window.element.setAttributeNS("http://www.w3.org/1999/xlink", "href", "");
+        shouldBeEmptyString("window.element.getAttributeNS('http://www.w3.org/1999/xlink', 'href')");
+        shouldBeEmptyString("window.element.getAttribute('href')");
+
+        window.element.setAttribute("href", "www.build.webkit.org");
+        shouldBeEqualToString("window.element.getAttributeNS('http://www.w3.org/1999/xlink', 'href')", "www.build.webkit.org");
+        shouldBeEqualToString("window.element.getAttribute('href')",  "www.build.webkit.org");
+
+        window.element.setAttribute("href", "");
+        shouldBeEmptyString("window.element.getAttributeNS('http://www.w3.org/1999/xlink', 'href')");
+        shouldBeEmptyString("window.element.getAttribute('href')");
+    </script>
+    <script src=""
+</body>

Modified: trunk/Source/WebCore/ChangeLog (234802 => 234803)


--- trunk/Source/WebCore/ChangeLog	2018-08-13 16:21:46 UTC (rev 234802)
+++ trunk/Source/WebCore/ChangeLog	2018-08-13 16:39:14 UTC (rev 234803)
@@ -1,3 +1,18 @@
+2018-08-13  Said Abou-Hallawa  <[email protected]>
+
+        Followup (r234683): Element::getAttribute() should return the first non-null attribute value
+        https://bugs.webkit.org/show_bug.cgi?id=188419
+
+        Reviewed by Darin Adler.
+
+        Element::getAttribute() should return the first non-null attribute value
+        since an empty string is a legitimate attribute value.
+
+        Test: svg/custom/href-svg-namespace-empty.html
+
+        * dom/Element.h:
+        (WebCore::Element::getAttribute const):
+
 2018-08-13  Michael Catanzaro  <[email protected]>
 
         Unreviewed, since -Wsign-compare warnings in URL.cpp

Modified: trunk/Source/WebCore/dom/Element.h (234802 => 234803)


--- trunk/Source/WebCore/dom/Element.h	2018-08-13 16:21:46 UTC (rev 234802)
+++ trunk/Source/WebCore/dom/Element.h	2018-08-13 16:39:14 UTC (rev 234803)
@@ -823,7 +823,7 @@
 inline const AtomicString& Element::getAttribute(const QualifiedName& name, const QualifiedNames&... names) const
 {
     const AtomicString& value = getAttribute(name);
-    if (!value.isEmpty())
+    if (!value.isNull())
         return value;
     return getAttribute(names...);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to