Skip to content

Commit

Permalink
Attach html element before calling on create li (#846)
Browse files Browse the repository at this point in the history
* Attach html element before calling onCreateLi

* Build
  • Loading branch information
mbraak authored Oct 17, 2024
1 parent 97fb9a5 commit 76d30ca
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/elementsRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ export default class ElementsRenderer {
const li = this.createLi(child, level);
ul.appendChild(li);

this.attachNodeData(child, li);

if (child.hasChildren()) {
this.createDomElements(li, child.children, false, level + 1);
}
Expand Down Expand Up @@ -156,6 +154,10 @@ export default class ElementsRenderer {
return li;
}

/* Create the <li> element
* Attach it to node.element.
* Call onCreateLi
*/
private createLi(node: Node, level: number): HTMLLIElement {
const isSelected = Boolean(this.isNodeSelected(node));

Expand All @@ -166,6 +168,8 @@ export default class ElementsRenderer {
? this.createFolderLi(node, level, isSelected)
: this.createNodeLi(node, level, isSelected);

this.attachNodeData(node, li);

if (this.onCreateLi) {
this.onCreateLi(node, jQuery(li), isSelected);
}
Expand Down Expand Up @@ -339,7 +343,6 @@ export default class ElementsRenderer {

// create element
const li = this.createLi(node, node.getLevel());
this.attachNodeData(node, li);

// add element to dom
$previousLi.after(li);
Expand Down
8 changes: 6 additions & 2 deletions tree.jquery.debug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tree.jquery.debug.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tree.jquery.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tree.jquery.js.map

Large diffs are not rendered by default.

0 comments on commit 76d30ca

Please sign in to comment.