Skip to content


Browse files Browse the repository at this point in the history
Make Attr.nodeValue/textContent not nullable

Reviewed by Chris Dumez.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.


This patch updates Attr value for 'nodeVAlue' and 'textContent' to
return empty string if null.


* Source/WebCore/dom/Attr.cpp:
(Attr::setNodeValue): As per commit message
* LayoutTests/fast/dom/coreDOM-element-attribute-js-null.xhtml: Rebaselined
* LayoutTests/fast/dom/coreDOM-element-attribute-js-null-expected.txt: Rebaselined

Canonical link:
  • Loading branch information
Ahmad-S792 authored and cdumez committed Jul 5, 2023
1 parent 8e5e36c commit 2da4c96
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
@@ -1,6 +1,8 @@
This test setting various attributes of a elements to JavaScript null.

TEST SUCCEEDED: The value was the string 'null'. [tested Attr.value]
TEST SUCCEEDED: The value was the empty string. [tested Attr.nodeValue]
TEST SUCCEEDED: The value was the empty string. [tested Attr.textContent]

TEST SUCCEEDED: The value was the empty string. [tested]

Expand Down
4 changes: 3 additions & 1 deletion LayoutTests/fast/dom/coreDOM-element-attribute-js-null.xhtml
Expand Up @@ -50,7 +50,9 @@
type: 'Attr',
elementToUse: document.createAttributeNS('','anAttribute'),
attributes: [
{name: 'value', expectedNull: 'null'}
{name: 'value', expectedNull: 'null'},
{name: 'nodeValue', expectedNull: ''},
{name: 'textContent', expectedNull: ''}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/dom/Attr.cpp
Expand Up @@ -103,7 +103,7 @@ void Attr::setValue(const AtomString& value)

void Attr::setNodeValue(const String& value)
setValue(AtomString { value });
setValue(value.isNull() ? emptyAtom() : AtomString(value));

Ref<Node> Attr::cloneNodeInternal(Document& targetDocument, CloningOperation)
Expand Down

0 comments on commit 2da4c96

Please sign in to comment.