I am writing a JS plugin that renders a custom widget. The code structure is like:
// It is stored somewhere like $:/plugins/LittleYe233/MyPlugin/widget.js, which is a normal tiddler
function foo() {
const node = $tw.utils.domMaker('div');
// ...
return node;
}
MyWidget.prototype.create = function(parent, nextSibling) {
let container = $tw.utils.domMaker('div');
// ...
const node = foo();
container.appendChild(node);
// ...
return container;
}
I found that container.appendChild(node)
was not working as expected (appending node
to container
), even if it worked in the browser console. I have searched in the Internet and still can’t figure it out. Any reply will be highly appreciated.