fix(field): added Date support to InteractionStateMixin
This commit is contained in:
parent
22bb75a868
commit
cfd78bdccc
2 changed files with 6 additions and 2 deletions
|
|
@ -60,7 +60,7 @@ export const InteractionStateMixin = dedupeMixin(
|
||||||
value = modelValue.viewValue;
|
value = modelValue.viewValue;
|
||||||
}
|
}
|
||||||
// Checks for empty platform types: Objects, Arrays, Dates
|
// Checks for empty platform types: Objects, Arrays, Dates
|
||||||
if (typeof value === 'object' && value !== null) {
|
if (typeof value === 'object' && value !== null && !(value instanceof Date)) {
|
||||||
return !!Object.keys(value).length;
|
return !!Object.keys(value).length;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-mixed-operators
|
// eslint-disable-next-line no-mixed-operators
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { InteractionStateMixin } from '../src/InteractionStateMixin.js';
|
||||||
export function runInteractionStateMixinSuite(customConfig) {
|
export function runInteractionStateMixinSuite(customConfig) {
|
||||||
const cfg = {
|
const cfg = {
|
||||||
tagString: null,
|
tagString: null,
|
||||||
allowedModelValueTypes: [Array, Object, Number, Boolean, String],
|
allowedModelValueTypes: [Array, Object, Number, Boolean, String, Date],
|
||||||
suffix: '',
|
suffix: '',
|
||||||
...customConfig,
|
...customConfig,
|
||||||
};
|
};
|
||||||
|
|
@ -154,6 +154,10 @@ export function runInteractionStateMixinSuite(customConfig) {
|
||||||
changeModelValueAndLeave('');
|
changeModelValueAndLeave('');
|
||||||
expect(el.prefilled, 'empty string should not be "prefilled"').to.be.false;
|
expect(el.prefilled, 'empty string should not be "prefilled"').to.be.false;
|
||||||
}
|
}
|
||||||
|
if (cfg.allowedModelValueTypes.includes(Date)) {
|
||||||
|
changeModelValueAndLeave(new Date());
|
||||||
|
expect(el.prefilled, 'Dates should be "prefilled"').to.be.true;
|
||||||
|
}
|
||||||
|
|
||||||
// Not prefilled
|
// Not prefilled
|
||||||
changeModelValueAndLeave(null);
|
changeModelValueAndLeave(null);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue