File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ * D E F
2
+ * A B C
3
+
4
+ ` E.insertAfter(B) -> `
5
+
6
+ * D F
7
+ * A B E C
8
+
9
+ * B
10
+ * _ next_ = C
11
+ * prev = A
12
+
13
+ * C
14
+ * next = null
15
+ * _ prev_ = B
16
+
17
+ * E
18
+ * _ next_ = F
19
+ * _ prev_ = D
20
+ * _ parent_ = ???
21
+
22
+ * D
23
+ * _ next_ = E
24
+ * _ prev_ = F
25
+
26
+ * F
27
+ * next = null
28
+ * _ prev_ = E
29
+
30
+ italic properties must change.
31
+
32
+ ``` D
33
+ // first, fix old nodes.
34
+ if(E == E.parent.firstChild) // nope
35
+ // E.prev must be null if this is true, short circuit logic?
36
+ E.parent.firstChild = E.next;
37
+ if(E == E.parent.lastChild) // nope
38
+ // E.next must be null if this is true, short circuit logic?
39
+ E.parent.lastChild = E.prev;
40
+ if(E.next) // F
41
+ E.next.prev = E.prev;
42
+ if(E.prev) // D
43
+ E.prev.next = E.next;
44
+ // insertBefore is an exact mirror of this beyond this point, and identical before.
45
+ // the links on E are free to scram now
46
+ E.prev = B;
47
+ E.next = B.next;
48
+
49
+ // now, set links to E
50
+
51
+ if(B.next) // C
52
+ B.next.prev = E;
53
+ B.next = E;
54
+ ```
You can’t perform that action at this time.
0 commit comments