Skip to content
Permalink
Browse files
Node.textContent = undefined should be equivalent to textContent = ""
https://bugs.webkit.org/show_bug.cgi?id=148729

Reviewed by Darin Adler.

Source/WebCore:

Assigning undefined to textContent should be equivalent to assigning an empty string to it like innerHTML.
This is because textContent is defined as an DOMString? attribute in DOM4 [1] and WebIDL defines ECMAScript
undefined to be treated as null for nullable types [2].

The new behavior matches that of Firefox and Chrome.

[1] https://dom.spec.whatwg.org/#node
[2] https://heycam.github.io/webidl/#es-nullable-type

* dom/Node.idl:

LayoutTests:

Rebaselined the test now that test cases pass.

* http/tests/w3c/dom/nodes/Node-textContent-expected.txt:


Canonical link: https://commits.webkit.org/166847@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189269 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
rniwa committed Sep 3, 2015
1 parent 079c732 commit fbe4edd67a8caae77c2dedf5f88ce11951c36cb1
Showing 4 changed files with 38 additions and 9 deletions.
@@ -1,3 +1,14 @@
2015-09-02 Ryosuke Niwa <rniwa@webkit.org>

Node.textContent = undefined should be equivalent to textContent = ""
https://bugs.webkit.org/show_bug.cgi?id=148729

Reviewed by Darin Adler.

Rebaselined the test now that test cases pass.

* http/tests/w3c/dom/nodes/Node-textContent-expected.txt:

2015-09-01 Alexey Proskuryakov <ap@apple.com>

Mark http/tests/contentfiltering/block-after-redirect.html as flaky for
@@ -24,14 +24,14 @@ PASS DocumentFragment without children set to null
PASS DocumentFragment with empty text node as child set to null
PASS DocumentFragment with children set to null
PASS DocumentFragment with descendants set to null
FAIL Element without children set to undefined assert_equals: expected "" but got "undefined"
FAIL Element with empty text node as child set to undefined assert_equals: expected "" but got "undefined"
FAIL Element with children set to undefined assert_equals: expected "" but got "undefined"
FAIL Element with descendants set to undefined assert_equals: expected "" but got "undefined"
FAIL DocumentFragment without children set to undefined assert_equals: expected "" but got "undefined"
FAIL DocumentFragment with empty text node as child set to undefined assert_equals: expected "" but got "undefined"
FAIL DocumentFragment with children set to undefined assert_equals: expected "" but got "undefined"
FAIL DocumentFragment with descendants set to undefined assert_equals: expected "" but got "undefined"
PASS Element without children set to undefined
PASS Element with empty text node as child set to undefined
PASS Element with children set to undefined
PASS Element with descendants set to undefined
PASS DocumentFragment without children set to undefined
PASS DocumentFragment with empty text node as child set to undefined
PASS DocumentFragment with children set to undefined
PASS DocumentFragment with descendants set to undefined
PASS Element without children set to ""
PASS Element with empty text node as child set to ""
PASS Element with children set to ""
@@ -1,3 +1,21 @@
2015-09-02 Ryosuke Niwa <rniwa@webkit.org>

Node.textContent = undefined should be equivalent to textContent = ""
https://bugs.webkit.org/show_bug.cgi?id=148729

Reviewed by Darin Adler.

Assigning undefined to textContent should be equivalent to assigning an empty string to it like innerHTML.
This is because textContent is defined as an DOMString? attribute in DOM4 [1] and WebIDL defines ECMAScript
undefined to be treated as null for nullable types [2].

The new behavior matches that of Firefox and Chrome.

[1] https://dom.spec.whatwg.org/#node
[2] https://heycam.github.io/webidl/#es-nullable-type

* dom/Node.idl:

2015-09-02 Alex Christensen <achristensen@webkit.org>

Make bison grammar compatible with bison 2.1
@@ -91,7 +91,7 @@
[TreatReturnedNullStringAs=Null] readonly attribute DOMString baseURI;

// FIXME: the spec says this can also raise on retrieval.
[TreatReturnedNullStringAs=Null, TreatNullAs=NullString, SetterRaisesException] attribute DOMString textContent;
[TreatReturnedNullStringAs=Null, TreatNullAs=NullString, TreatUndefinedAs=NullString, SetterRaisesException] attribute DOMString textContent;

boolean isSameNode([Default=Undefined] optional Node other);
boolean isEqualNode([Default=Undefined] optional Node other);

0 comments on commit fbe4edd

Please sign in to comment.