Commit e1d20063 authored by ch.dumez@samsung.com's avatar ch.dumez@samsung.com

Node.textContent setter should treat undefined the same way as null

Node.textContent setter should treat undefined the same way as null.
Previously, undefined would get stringified to "undefined" in the
setter, instead of being treated as "". This is inconsistent with
what happens when assigning null and with the DOM specification:
http://dom.spec.whatwg.org/#dom-node-textcontent

Since the textContent attribute is nullable, both null and undefined
input should be treated as null as per the Web IDL specification:
http://heycam.github.io/webidl/#es-nullable-type

The new behavior is consistent with Firefox 29. However, IE11 returns
"undefined" in this case.

R=arv@chromium.org, tkent@chromium.org
BUG=378454
TEST=fast/dom/Node/textContent-set-undefined.html

Review URL: https://codereview.chromium.org/303163002

git-svn-id: svn://svn.chromium.org/blink/trunk@175103 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 2466df81
<!DOCTYPE html>
<html>
<head>
<link rel="help" href="http://dom.spec.whatwg.org/#dom-node-textcontent">
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<div id="testDiv">test</div>
<script>
test(function() {
var testDiv = document.getElementById("testDiv");
assert_equals(testDiv.textContent, "test");
testDiv.textContent = null;
assert_equals(testDiv.textContent, "");
testDiv.textContent = "test";
assert_equals(testDiv.textContent, "test");
testDiv.textContent = undefined;
assert_equals(testDiv.textContent, "");
}, "Test that setting Node.textContent to undefined does the same as null");
</script>
</body>
</html>
......@@ -67,7 +67,7 @@
// Introduced in DOM Level 3:
[TreatReturnedNullStringAs=Null] readonly attribute DOMString baseURI;
[TreatReturnedNullStringAs=Null, TreatNullAs=NullString, CustomElementCallbacks] attribute DOMString textContent;
[TreatReturnedNullStringAs=Null, TreatNullAs=NullString, TreatUndefinedAs=NullString, CustomElementCallbacks] attribute DOMString textContent;
[MeasureAs=NodeIsSameNode] boolean isSameNode([Default=Undefined] optional Node other); // Removed in DOM4.
boolean isEqualNode(Node other);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment