Api: Allow Web Components to be added into templates (.xet files)

Current limitations:
- display only, I haven't figured out getting values back yet
- no children in the web components
This commit is contained in:
nathangray
2021-06-18 14:20:17 -06:00
parent 498cb2994d
commit 78a01ced17
4 changed files with 71 additions and 12 deletions

View File

@ -148,7 +148,7 @@ export class et2_DOMWidget extends et2_widget {
*/
insertChild(_node, _idx) {
super.insertChild(_node, _idx);
if (_node.instanceOf(et2_DOMWidget) && typeof _node.hasOwnProperty('parentNode') && this.getDOMNode(this)) {
if (_node.instanceOf && _node.instanceOf(et2_DOMWidget) && typeof _node.hasOwnProperty('parentNode') && this.getDOMNode(this)) {
try {
_node.setParentDOMNode(this.getDOMNode(_node));
}
@ -157,6 +157,10 @@ export class et2_DOMWidget extends et2_widget {
// will probably try again in doLoadingFinished()
}
}
// _node is actually a Web Component
else if (_node instanceof Element) {
this.getDOMNode().append(_node);
}
}
isAttached() {
return this.parentNode != null;