Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.

Commit 63eee2c

Browse files
Adrián González Rusadrigzr
authored andcommitted
fix: add observer to node content
1 parent d69f6b7 commit 63eee2c

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

addon/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,22 @@ function initializeCustomElement(elementName, { name: componentName, attributes:
150150
options.onConnect.call(self);
151151
}
152152

153+
const observer = new MutationObserver(() => {
154+
if (this.context) {
155+
this.context.set('content', this.innerHTML);
156+
}
157+
});
158+
159+
// eslint-disable-next-line ember/no-observers
160+
observer.observe(this, { childList: true });
161+
153162
schedule('afterRender', () => {
154163
const attrs = getAttributeList(self);
155-
const template = compileTemplate(`{{#${componentName} ${attrs}}}${self.innerHTML}{{/${componentName}}}`);
164+
const template = compileTemplate(`{{#${componentName} ${attrs}}}{{content}}{{/${componentName}}}`);
156165
const { toplevelView, controller } = renderTemplate(owner, template);
157166

167+
controller.set('content', self.innerHTML);
168+
158169
setAttributes(controller, self);
159170

160171
self.context = controller;

0 commit comments

Comments
 (0)