Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1366)

Unified Diff: third_party/WebKit/Source/core/html/HTMLInputElement.cpp

Issue 2417753003: Input element: Fix the dirty value flag after type change. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/forms/input-type-change3-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLInputElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
index 653a4dd7c2a744354bcc1e2ab51421b72d634dc4..7acf9f402fdb1a966113b2b3a293182c44865dd9 100644
--- a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
@@ -431,16 +431,29 @@ void HTMLInputElement::updateType() {
bool willStoreValue = m_inputType->storesValueSeparateFromAttribute();
+ // https://html.spec.whatwg.org/multipage/forms.html#input-type-change
+ //
+ // 1. If the previous state of the element's type attribute put the value IDL
+ // attribute in the value mode, and the element's value is not the empty
+ // string, and the new state of the element's type attribute puts the value
+ // IDL attribute in either the default mode or the default/on mode, then set
+ // the element's value content attribute to the element's value.
if (didStoreValue && !willStoreValue && hasDirtyValue()) {
setAttribute(valueAttr, AtomicString(m_valueIfDirty));
m_valueIfDirty = String();
m_hasDirtyValue = false;
}
+ // 2. Otherwise, if the previous state of the element's type attribute put the
+ // value IDL attribute in any mode other than the value mode, and the new
+ // state of the element's type attribute puts the value IDL attribute in the
+ // value mode, then set the value of the element to the value of the value
+ // content attribute, if there is one, or the empty string otherwise, and then
+ // set the control's dirty value flag to false.
if (!didStoreValue && willStoreValue) {
AtomicString valueString = fastGetAttribute(valueAttr);
m_inputType->warnIfValueIsInvalid(valueString);
- m_valueIfDirty = sanitizeValue(valueString);
- m_hasDirtyValue = !m_valueIfDirty.isNull();
+ m_valueIfDirty = String();
+ m_hasDirtyValue = false;
} else {
if (!hasDirtyValue())
m_inputType->warnIfValueIsInvalid(
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/forms/input-type-change3-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698