aw-front-helpers 2.5.5 → 2.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -103,23 +103,26 @@ export default class FormControl {
103
103
  if (parent === null) return;
104
104
  let error = parent.querySelector(`.${this._options.classErrorElement}`);
105
105
  parent.classList.add(this._options.classIsError);
106
+ const id = `error-${[...Array(6)].map(() => Math.floor(Math.random() * 16).toString(16)).join('')}`;
106
107
  if (!error) {
107
108
  error = Object.assign(
108
109
  document.createElement('p'), {
109
- className: this._options.classErrorElement,
110
- innerHTML: message
110
+ id,
111
+ className: this._options.classErrorElement,
112
+ innerHTML: message
111
113
  });
112
- error.setAttribute('aria-describedby', element.id);
114
+ element.setAttribute('aria-describedby', id);
113
115
  parent.appendChild(error);
114
116
  } else {
115
117
  if (error.tagName === 'P') {
116
118
  if (message === error.innerHTML) return;
117
119
  const newError = Object.assign(
118
120
  document.createElement('ul'), {
119
- className: this._options.classErrorElement,
120
- innerHTML: `<li>${error.innerHTML}</li>`
121
+ id,
122
+ className: this._options.classErrorElement,
123
+ innerHTML: `<li>${error.innerHTML}</li>`
121
124
  });
122
- newError.setAttribute('aria-describedby', element.id);
125
+ element.setAttribute('aria-describedby', id);
123
126
  parent.appendChild(newError);
124
127
  error.parentNode.removeChild(error);
125
128
  error = newError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aw-front-helpers",
3
- "version": "2.5.5",
3
+ "version": "2.5.6",
4
4
  "description": "Assets helpers for projects",
5
5
  "author": "Yoann Le Poupon",
6
6
  "license": "ISC",