Skip to content

Commit 6d26e38

Browse files
author
Graham Butler
committed
fix transformChild bug
1 parent 888e726 commit 6d26e38

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@author.io/element-control",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "author-control custom element (web component).",
55
"main": "dist/author-control.min.js",
66
"scripts": {

src/element.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,18 @@ class AuthorFormControlElement extends AuthorBaseElement(HTMLElement) {
195195
this.PRIVATE.initSelectSurrogate(select, document.createElement('author-select'))
196196
},
197197

198-
transformChild: node => {
198+
transformChild: (node, collection) => {
199199
switch (node.nodeName) {
200200
case 'LABEL':
201201
return this.PRIVATE.initLabel(node)
202202

203203
case 'INPUT':
204204
// Check if there is an additional element adjacent to the input
205-
if (array[index + 1] === void 0) {
205+
if (collection[index + 1] === void 0) {
206206
return this.PRIVATE.initInput(node)
207207
}
208208

209-
let adjacentElement = array[index + 1].addedNodes.item(0);
209+
let adjacentElement = collection[index + 1].addedNodes.item(0);
210210

211211
if (!adjacentElement || adjacentElement.nodeName !== 'DATALIST') {
212212
return this.PRIVATE.initInput(node)
@@ -249,15 +249,15 @@ class AuthorFormControlElement extends AuthorBaseElement(HTMLElement) {
249249
return
250250
}
251251

252-
this.PRIVATE.transformChild(node)
252+
this.PRIVATE.transformChild(node, array)
253253
})
254254

255255
observer.disconnect()
256256
})
257257

258258
this.UTIL.registerListeners(this, {
259259
connected: () => this.PRIVATE.guid = this.UTIL.generateGuid('control_'),
260-
rendered: () => Array.from(this.children).forEach(child => this.PRIVATE.transformChild(child))
260+
rendered: () => Array.from(this.children).forEach((child, index, array) => this.PRIVATE.transformChild(child, array))
261261
})
262262
}
263263

0 commit comments

Comments
 (0)