Commit 5c44539d authored by Jiewei Qian's avatar Jiewei Qian Committed by 杨奕

DatePicker: guards common but incorrect usage (#11673)

parent 8f9986f8
...@@ -508,12 +508,21 @@ export default { ...@@ -508,12 +508,21 @@ export default {
}, },
parsedValue() { parsedValue() {
const isParsed = isDateObject(this.value) || (Array.isArray(this.value) && this.value.every(isDateObject)); if (!this.value) return this.value; // component value is not set
if (this.valueFormat && !isParsed) { if (this.type === 'time-select') return this.value; // time-select does not require parsing, this might change in next major version
return parseAsFormatAndType(this.value, this.valueFormat, this.type, this.rangeSeparator) || this.value;
} else { const valueIsDateObject = isDateObject(this.value) || (Array.isArray(this.value) && this.value.every(isDateObject));
if (valueIsDateObject) {
return this.value; return this.value;
} }
if (this.valueFormat) {
return parseAsFormatAndType(this.value, this.valueFormat, this.type, this.rangeSeparator) || this.value;
}
// NOTE: deal with common but incorrect usage, should remove in next major version
// user might provide string / timestamp without value-format, coerce them into date (or array of date)
return Array.isArray(this.value) ? this.value.map(val => new Date(val)) : new Date(this.value);
}, },
_elFormItemSize() { _elFormItemSize() {
......
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