@@ -18,15 +18,15 @@ let a = {foo: 'bar'}; // or `new Whatever()`
18
18
let b = {foo: ' baz' };
19
19
let c = {foo: ' qux' };
20
20
21
- tree .insertBefore (a, b ); // insert a before b
22
- tree .insertAfter (c, b ); // insert c after b
21
+ tree .insertBefore (b, a ); // insert a before b
22
+ tree .insertAfter (b, c ); // insert c after b
23
23
24
- console .log (tree .next (a) === b);
25
- console .log (tree .next (b) === c);
26
- console .log (tree .prev (c) === b);
24
+ console .log (tree .nextSibling (a) === b);
25
+ console .log (tree .nextSibling (b) === c);
26
+ console .log (tree .previousSibling (c) === b);
27
27
28
28
tree .remove (b);
29
- console .log (tree .next (a) === c);
29
+ console .log (tree .nextSibling (a) === c);
30
30
```
31
31
32
32
A tree:
@@ -40,17 +40,17 @@ let a = {};
40
40
let b = {};
41
41
let c = {};
42
42
43
- tree .insertFirst (a, parent ); // insert a as the first child
44
- tree .insertLast (c, parent ); // insert c as the last child
45
- tree .insertAfter (b, a ); // insert b after a, it now has the same parent as a
43
+ tree .prependChild (parent, a ); // insert a as the first child
44
+ tree .appendChild (parent,c ); // insert c as the last child
45
+ tree .insertAfter (a, b ); // insert b after a, it now has the same parent as a
46
46
47
- console .log (tree .first (parent) === a);
48
- console .log (tree .next (tree .first (parent)) === b);
49
- console .log (tree .last (parent) === c);
47
+ console .log (tree .firstChild (parent) === a);
48
+ console .log (tree .nextSibling (tree .firstChild (parent)) === b);
49
+ console .log (tree .lastChild (parent) === c);
50
50
51
51
let grandparent = {};
52
- tree .insertFirst (parent, grandparent );
53
- console .log (tree .first (tree .first (grandparent)) === a);
52
+ tree .prependChild (grandparent, parent );
53
+ console .log (tree .firstChild (tree .firstChild (grandparent)) === a);
54
54
```
55
55
56
56
See [ api.md] ( api.md ) for more documentation.
0 commit comments