1 $group
2 if !window.wz
3 set window.wz = {}
4 set wz.node = {}
5 set wz.node.remove
6 function
7 param node
8 if !node.parent
9 throw new Error('Node must have a parent')
10 if !node.parent.children
11 throw new Error('Node parent must must have a children property')
12 var index = node.parent.children.indexOf(node)
13 if index < 0
14 throw new Error('Node must be child of its parent property')
15 _ node.parent.children.splice(index, 1)
16 return index
17 set wz.node.replace
18 function
19 param node
20 param newnode
21 if !node.parent
22 throw new Error('Node must have a parent')
23 if !node.parent.children
24 throw new Error('Node parent must must have a children property')
25 var index = node.parent.children.indexOf(node)
26 if index < 0
27 throw new Error('Node must be child of its parent property')
28 set newnode.parent = node.parent
29 _ node.parent.children[index] = newnode