Skip to content

Commit

Permalink
Optimized setting parent node by skipping getNodeById function.
Browse files Browse the repository at this point in the history
  • Loading branch information
michielvandergeest committed Oct 11, 2023
1 parent b956ddf commit 6618e4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ const transformations = {
'z' in props && (props.zIndex = props.z)
delete props.z
},
parentId(props) {
props.parent = props.parentId === 'root' ? renderer.root : renderer.getNodeById(props.parentId)
delete props.parentId
parent(props) {
if (props.parent === 'root') {
props.parent = renderer.root
} else {
props.parent = props.parent.node
}
},
color(props) {
if (
Expand Down
2 changes: 1 addition & 1 deletion src/lib/codegenerator/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const generateElementCode = function (

renderCode.push(`
if(!${elm}) {
${elm} = this.element({componentId: component.___id, parentId: parent && parent.nodeId || 'root'})
${elm} = this.element({componentId: component.___id, parent: parent || 'root'})
}
const elementConfig${counter} = {}
`)
Expand Down

0 comments on commit 6618e4e

Please sign in to comment.