Skip to content

Commit c131a2d

Browse files
committed
Add skipChangeValidation utility function
1 parent 213da79 commit c131a2d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/element-utilities.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ export function skipInputValidation(element) {
1919
return !element.hasAttribute(`data-live-validation`)
2020
}
2121

22+
/**
23+
* Checks if the given `element` has the `data-change-validation` attribute
24+
* @param {Element} element
25+
* @return {boolean} Returns true if the element does not have the `data-change-validation` attribute`
26+
*/
27+
export function skipChangeValidation(element) {
28+
return !element.hasAttribute(`data-change-validation`)
29+
}
30+
2231
/**
2332
* Checks if the given `element` has the `data-focusout-validation` attribute
2433
* @param {Element} element

test/element-utilities.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ suite('Element Utilities', async () => {
3333
assert.equal(true, ElementUtils.skipInputValidation(el))
3434
})
3535

36+
test(`skipChangeValidation`, async() => {
37+
const el = await fixture(html`
38+
<input type="text" data-change-validation>
39+
`);
40+
41+
assert.equal(false, ElementUtils.skipChangeValidation(el))
42+
43+
el.removeAttribute(`data-change-validation`)
44+
45+
assert.equal(true, ElementUtils.skipChangeValidation(el))
46+
})
47+
3648
test(`skipFocusoutValidation`, async() => {
3749
const el = await fixture(html`
3850
<input type="text" data-focusout-validation>

0 commit comments

Comments
 (0)