Skip to content

Commit 6032dd9

Browse files
committed
Add getErrorListFromContainer helper method
1 parent 21fa894 commit 6032dd9

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/error-containers.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ export function getErrorContainer(element) {
4040
* @returns {Element} The `ul` element inside the error container`
4141
*/
4242
export function getErrorList(element) {
43-
return getErrorContainer(element).querySelector(`:scope > ul`)
43+
return getErrorListFromContainer(getErrorContainer(element))
44+
}
45+
46+
/**
47+
* Returns the `ul` inside of the error container (see {@link getErrorContainer })
48+
* @param {Element} container the error list container
49+
* @returns {Element} The `ul` element inside the error container`
50+
*/
51+
export function getErrorListFromContainer(container) {
52+
return container.querySelector(`:scope > ul`)
4453
}
4554

4655
/**

src/error-mapping.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44

55
import {
66
getErrorContainer,
7+
getErrorListFromContainer,
78
hasPreservedErrorForType,
89
getPreservedErrorForType,
910
markAsPreservedError,
@@ -66,7 +67,7 @@ export function applyErrorMappingToForm(form, errors) {
6667
setValidityStateAttributes(elementToInvalidate, false)
6768
}
6869

69-
let errorList = errorContainer.querySelector(`:scope > ul`)
70+
let errorList = getErrorListFromContainer(errorContainer)
7071

7172
const shouldBePreserved = hasPreservedErrorForType(errorList, error.type)
7273

0 commit comments

Comments
 (0)