Skip to content

Commit 77bc21e

Browse files
author
Graham Butler
committed
remove mutation observer
1 parent bd10c24 commit 77bc21e

File tree

4 files changed

+29
-30
lines changed

4 files changed

+29
-30
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.13",
3+
"version": "1.0.14",
44
"description": "author-control custom element (web component).",
55
"main": "dist/author-control.min.js",
66
"scripts": {

showroom/src/js/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ const Demo = new NGNX.VIEW.Registry({
22
selector: '.demo',
33
namespace: 'demo.',
44

5+
references: {
6+
content: 'main .content'
7+
},
8+
9+
templates: {
10+
select: './js/templates/select.html'
11+
},
12+
513
init () {
6-
console.log('works');
14+
this.render('select', {}, this.ref.content.element)
715
}
816
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<author-control>
2+
<label>Rendered Select</label>
3+
<select>
4+
<option>Option 1</option>
5+
<option>Option 2</option>
6+
<option>Option 3</option>
7+
</select>
8+
</author-control>

src/element.js

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ class AuthorFormControlElement extends AuthorBaseElement(HTMLElement) {
77
})
88

99
this.UTIL.defineProperties({
10+
initialized: {
11+
private: true,
12+
default: false
13+
},
14+
1015
initialValue: {
1116
default: null
1217
},
@@ -168,8 +173,8 @@ class AuthorFormControlElement extends AuthorBaseElement(HTMLElement) {
168173
break
169174
}
170175

176+
this.PRIVATE.initialized = true
171177
this.emit('initialized')
172-
return console.dir(this);
173178
},
174179

175180
initAuthorDatalist: () => {
@@ -246,34 +251,12 @@ class AuthorFormControlElement extends AuthorBaseElement(HTMLElement) {
246251
}
247252
})
248253

249-
this.UTIL.monitorChildren((mutations, observer) => {
250-
let filtered = mutations.filter(record => {
251-
let node = record.addedNodes.item(0)
252-
253-
if (!node) {
254-
return false
255-
}
256-
257-
return node.nodeType !== 3
258-
})
259-
260-
filtered.forEach((record, index, array) => {
261-
let node = record.addedNodes.item(0)
262-
263-
if (!node) {
264-
return
265-
}
266-
267-
this.PRIVATE.catalogChild(node)
268-
// this.PRIVATE.transformChild(node, index, array.map(mutation => mutation.addedNodes.item(0)))
269-
})
270-
271-
observer.disconnect()
272-
this.PRIVATE.init()
273-
})
274-
275254
this.UTIL.registerListeners(this, {
276-
connected: () => this.PRIVATE.guid = this.UTIL.generateGuid('control_')
255+
connected: () => this.PRIVATE.guid = this.UTIL.generateGuid('control_'),
256+
rendered: () => {
257+
Array.from(this.children).forEach(child => this.PRIVATE.catalogChild(child))
258+
this.PRIVATE.init()
259+
}
277260
})
278261
}
279262

0 commit comments

Comments
 (0)