Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Setting HTMLInputElement.value to null to set its value to the empty …
…string https://bugs.webkit.org/show_bug.cgi?id=153519 Reviewed by Ryosuke Niwa. Source/WebCore: Setting HTMLInputElement.value to null to set its value to the empty string: - https://html.spec.whatwg.org/#htmlinputelement - http://heycam.github.io/webidl/#TreatNullAs WebKit would previously unset the value attribute instead, which caused it to fallback to input.defaultValue if set. Firefox and Chrome behave correctly. Test: fast/dom/HTMLInputElement/input-value-set-null.html * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::setValue): LayoutTests: Add a layout test to make sure that setting HTMLInputElement.value to null actually sets its value to the empty string. * fast/dom/HTMLInputElement/input-value-set-null-expected.txt: Added. * fast/dom/HTMLInputElement/input-value-set-null.html: Added. Canonical link: https://commits.webkit.org/171589@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195642 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
5 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
LayoutTests/fast/dom/HTMLInputElement/input-value-set-null-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Checks that setting input.value to null sets the input value to the empty string. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
input.defaultValue = 'defaultValue' | ||
PASS input.value is "defaultValue" | ||
input.value = null | ||
PASS input.value is "" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
15 changes: 15 additions & 0 deletions
15
LayoutTests/fast/dom/HTMLInputElement/input-value-set-null.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<script src="../../../resources/js-test-pre.js"></script> | ||
<script> | ||
description("Checks that setting input.value to null sets the input value to the empty string."); | ||
|
||
var input = document.createElement("input"); | ||
evalAndLog("input.defaultValue = 'defaultValue'"); | ||
|
||
shouldBeEqualToString("input.value", "defaultValue"); | ||
|
||
// HTMLInputElement.value treats null as the empty String so this should set the value to "". | ||
evalAndLog("input.value = null"); | ||
shouldBeEqualToString("input.value", ""); | ||
</script> | ||
<script src="../../../resources/js-test-post.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters