@zywave/zui-base
Advanced tools
Comparing version 4.3.0-pre.0 to 4.3.0-pre.1
@@ -51,3 +51,4 @@ import { ZuiBaseElement } from './zui-base.js'; | ||
/** | ||
* Returns a {@link https://developer.mozilla.org/en-US/docs/Web/API/ValidityState | ValidityState} object that represents the validity states of an element | ||
* Returns a ValidityState object that represents the validity states of an element. | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ValidityState} | ||
*/ | ||
@@ -77,3 +78,3 @@ get validity(): ValidityState; | ||
/** | ||
* Sets a custom error message to be displayed when the element is checked for validity. Set to empty string to remove the custom error. <strong>Note:</strong> that consumers must clear the custom error; the component will not automatically clear it. | ||
* Sets a custom error message to be displayed when the element is checked for validity. Set to empty string to remove the custom error. <strong>Note:</strong> consumers must clear the custom error; the component will not automatically clear it. | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity | setCustomValidity} | ||
@@ -80,0 +81,0 @@ * @param message - The error message to be displayed when the element is checked for validity |
@@ -82,3 +82,4 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
/** | ||
* Returns a {@link https://developer.mozilla.org/en-US/docs/Web/API/ValidityState | ValidityState} object that represents the validity states of an element | ||
* Returns a ValidityState object that represents the validity states of an element. | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ValidityState} | ||
*/ | ||
@@ -193,3 +194,3 @@ get validity() { | ||
/** | ||
* Sets a custom error message to be displayed when the element is checked for validity. Set to empty string to remove the custom error. <strong>Note:</strong> that consumers must clear the custom error; the component will not automatically clear it. | ||
* Sets a custom error message to be displayed when the element is checked for validity. Set to empty string to remove the custom error. <strong>Note:</strong> consumers must clear the custom error; the component will not automatically clear it. | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity | setCustomValidity} | ||
@@ -200,3 +201,6 @@ * @param message - The error message to be displayed when the element is checked for validity | ||
if (message) { | ||
this.#priorValidationMessage = this.validationMessage; | ||
// preserve the validity message if the current validity state is not already a custom error | ||
if (!this.validity.customError) { | ||
this.#priorValidationMessage = this.validationMessage; | ||
} | ||
this.#internals?.setValidity({ ...cloneValidityState(this.validity), customError: true }, message, this._focusControl); | ||
@@ -203,0 +207,0 @@ } |
{ | ||
"name": "@zywave/zui-base", | ||
"version": "4.3.0-pre.0", | ||
"version": "4.3.0-pre.1", | ||
"main": "dist/index.js", | ||
@@ -17,3 +17,4 @@ "module": "dist/index.js", | ||
"watch": "npm-run-all build --parallel watcher:start launch-server", | ||
"watcher:start": "node ../../../scripts/node/watcher.mjs" | ||
"watcher:start": "node ../../../scripts/node/watcher.mjs", | ||
"analyze": "cem analyze --globs src/zui-*.ts --litelement --outdir dist" | ||
}, | ||
@@ -23,3 +24,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "6e976d90d934483b6dedeec9475d7c40cbba8a33" | ||
"gitHead": "273e492feca3e8a48dbfe1c2fda93f422cdc13a3" | ||
} |
@@ -106,3 +106,4 @@ import { ZuiBaseElement } from './zui-base.js'; | ||
/** | ||
* Returns a {@link https://developer.mozilla.org/en-US/docs/Web/API/ValidityState | ValidityState} object that represents the validity states of an element | ||
* Returns a ValidityState object that represents the validity states of an element. | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ValidityState} | ||
*/ | ||
@@ -222,3 +223,3 @@ get validity(): ValidityState { | ||
/** | ||
* Sets a custom error message to be displayed when the element is checked for validity. Set to empty string to remove the custom error. <strong>Note:</strong> that consumers must clear the custom error; the component will not automatically clear it. | ||
* Sets a custom error message to be displayed when the element is checked for validity. Set to empty string to remove the custom error. <strong>Note:</strong> consumers must clear the custom error; the component will not automatically clear it. | ||
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity | setCustomValidity} | ||
@@ -229,3 +230,6 @@ * @param message - The error message to be displayed when the element is checked for validity | ||
if (message) { | ||
this.#priorValidationMessage = this.validationMessage; | ||
// preserve the validity message if the current validity state is not already a custom error | ||
if (!this.validity.customError) { | ||
this.#priorValidationMessage = this.validationMessage; | ||
} | ||
this.#internals?.setValidity( | ||
@@ -232,0 +236,0 @@ { ...cloneValidityState(this.validity), customError: true }, |
@@ -491,2 +491,10 @@ // eslint-disable-next-line @typescript-eslint/triple-slash-reference | ||
element.setCustomValidity('bar'); | ||
validationMessage = element.validationMessage; | ||
validity = element.validity; | ||
assert.equal(validationMessage, 'bar'); | ||
assert.equal(validity.valid, false, 'valid should be false'); | ||
assert.equal(validity.customError, true, 'customError should be true'); | ||
assert.equal(validity.valueMissing, true, 'valueMissing should be true'); | ||
element.setCustomValidity(''); | ||
@@ -493,0 +501,0 @@ validationMessage = element.validationMessage; |
Sorry, the diff of this file is not supported yet
122290
49
1985