Title: [205079] trunk
Revision
205079
Author
[email protected]
Date
2016-08-27 10:45:12 -0700 (Sat, 27 Aug 2016)

Log Message

script.text should behave like script.textContent on setting
<https://webkit.org/b/148852>

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-expected.txt:

Source/WebCore:

HTMLScriptElement.text should behave just like .textContent when setting,
so just forward setText() to setTextContent().

Test: import/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text.html

* html/HTMLScriptElement.cpp:
(WebCore::HTMLScriptElement::setText):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (205078 => 205079)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-08-27 15:09:34 UTC (rev 205078)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-08-27 17:45:12 UTC (rev 205079)
@@ -1,3 +1,12 @@
+2016-08-27  Andreas Kling  <[email protected]>
+
+        script.text should behave like script.textContent on setting
+        <https://webkit.org/b/148852>
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-expected.txt:
+
 2016-08-27  Youenn Fablet  <[email protected]>
 
         Sync web-platform-tests up to revision e827374

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-expected.txt (205078 => 205079)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-expected.txt	2016-08-27 15:09:34 UTC (rev 205078)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text-expected.txt	2016-08-27 17:45:12 UTC (rev 205079)
@@ -1,8 +1,8 @@
 
 PASS Getter 
 PASS Setter (non-empty string) 
-FAIL Setter (empty string) assert_equals: expected null but got Text node ""
+PASS Setter (empty string) 
 PASS Setter (null) 
 PASS Setter (undefined) 
-FAIL Setter (text node reuse) assert_not_equals: got disallowed value Text node "two"
+PASS Setter (text node reuse) 
 

Modified: trunk/Source/WebCore/ChangeLog (205078 => 205079)


--- trunk/Source/WebCore/ChangeLog	2016-08-27 15:09:34 UTC (rev 205078)
+++ trunk/Source/WebCore/ChangeLog	2016-08-27 17:45:12 UTC (rev 205079)
@@ -1,3 +1,18 @@
+2016-08-27  Andreas Kling  <[email protected]>
+
+        script.text should behave like script.textContent on setting
+        <https://webkit.org/b/148852>
+
+        Reviewed by Chris Dumez.
+
+        HTMLScriptElement.text should behave just like .textContent when setting,
+        so just forward setText() to setTextContent().
+
+        Test: import/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/script-text.html
+
+        * html/HTMLScriptElement.cpp:
+        (WebCore::HTMLScriptElement::setText):
+
 2016-08-27  Youenn Fablet  <[email protected]>
 
         [Fetch API] Blob type should be set from Response/Request contentType header

Modified: trunk/Source/WebCore/html/HTMLScriptElement.cpp (205078 => 205079)


--- trunk/Source/WebCore/html/HTMLScriptElement.cpp	2016-08-27 15:09:34 UTC (rev 205078)
+++ trunk/Source/WebCore/html/HTMLScriptElement.cpp	2016-08-27 17:45:12 UTC (rev 205079)
@@ -79,19 +79,10 @@
     ScriptElement::finishedInsertingSubtree();
 }
 
+// https://html.spec.whatwg.org/multipage/scripting.html#dom-script-text
 void HTMLScriptElement::setText(const String& value)
 {
-    Ref<HTMLScriptElement> protectedThis(*this);
-
-    if (hasOneChild() && is<Text>(*firstChild())) {
-        downcast<Text>(*firstChild()).setData(value);
-        return;
-    }
-
-    if (hasChildNodes())
-        removeChildren();
-
-    appendChild(document().createTextNode(value), IGNORE_EXCEPTION);
+    setTextContent(value, ASSERT_NO_EXCEPTION);
 }
 
 void HTMLScriptElement::setAsync(bool async)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to