I have a weird problem where the rendered layout of a tiddler is not according to the order of the wiki text. It is kind of hard for me to replicate in a clean wiki as it has to do with some hacks I have. So trying my luck to see if I can get an answer without one.
Consider this snippet from ElementWidget.render.prototype:
// Invoke the th-rendering-element hook
var parseTreeNodes = $tw.hooks.invokeHook("th-rendering-element",null,this);
this.isReplaced = !!parseTreeNodes;
if(parseTreeNodes) {
// Use the parse tree nodes provided by the hook
this.makeChildWidgets(parseTreeNodes);
this.renderChildren(this.parentDomNode,null);
return;
}
// Make the child widgets
this.makeChildWidgets();
// Create the DOM node and render children
var domNode = this.document.createElementNS(this.namespace,this.tag);
this.assignAttributes(domNode,{excludeEventAttributes: true});
parent.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null);
this.domNodes.push(domNode);
The parseTreeNodes can be replaced in a listener of the th-rendering-hook, but when it is the line this.domNodes.push(domNode)
is not called. Can this cause a change of layout sometimes? In my case an element that should be below the one where the parseTreeNodes was replaced is rendered above it.