@@ -30,15 +30,11 @@ describe('runtime-dom: node-ops', () => {
30
30
test ( 'fresh insertion' , ( ) => {
31
31
const content = `<div>one</div><div>two</div>three`
32
32
const parent = document . createElement ( 'div' )
33
- const [ first , last ] = nodeOps . insertStaticContent ! (
34
- content ,
35
- parent ,
36
- null ,
37
- false
38
- )
33
+ const nodes = nodeOps . insertStaticContent ! ( content , parent , null , false )
39
34
expect ( parent . innerHTML ) . toBe ( content )
40
- expect ( first ) . toBe ( parent . firstChild )
41
- expect ( last ) . toBe ( parent . lastChild )
35
+ expect ( nodes . length ) . toBe ( 3 )
36
+ expect ( nodes [ 0 ] ) . toBe ( parent . firstChild )
37
+ expect ( nodes [ nodes . length - 1 ] ) . toBe ( parent . lastChild )
42
38
} )
43
39
44
40
test ( 'fresh insertion with anchor' , ( ) => {
@@ -47,15 +43,13 @@ describe('runtime-dom: node-ops', () => {
47
43
const parent = document . createElement ( 'div' )
48
44
parent . innerHTML = existing
49
45
const anchor = parent . firstChild
50
- const [ first , last ] = nodeOps . insertStaticContent ! (
51
- content ,
52
- parent ,
53
- anchor ,
54
- false
55
- )
46
+ const nodes = nodeOps . insertStaticContent ! ( content , parent , anchor , false )
56
47
expect ( parent . innerHTML ) . toBe ( content + existing )
57
- expect ( first ) . toBe ( parent . firstChild )
58
- expect ( last ) . toBe ( parent . childNodes [ parent . childNodes . length - 2 ] )
48
+ expect ( nodes . length ) . toBe ( 3 )
49
+ expect ( nodes [ 0 ] ) . toBe ( parent . firstChild )
50
+ expect ( nodes [ nodes . length - 1 ] ) . toBe (
51
+ parent . childNodes [ parent . childNodes . length - 2 ]
52
+ )
59
53
} )
60
54
61
55
test ( 'fresh insertion as svg' , ( ) => {
@@ -97,7 +91,7 @@ describe('runtime-dom: node-ops', () => {
97
91
const content = `<div>one</div><div>two</div>three`
98
92
99
93
const cacheParent = document . createElement ( 'div' )
100
- const [ cachedFirst , cachedLast ] = nodeOps . insertStaticContent ! (
94
+ const nodes = nodeOps . insertStaticContent ! (
101
95
content ,
102
96
cacheParent ,
103
97
null ,
@@ -106,20 +100,18 @@ describe('runtime-dom: node-ops', () => {
106
100
107
101
const parent = document . createElement ( 'div' )
108
102
109
- const [ first , last ] = nodeOps . insertStaticContent ! (
103
+ const clonedNodes = nodeOps . insertStaticContent ! (
110
104
`` ,
111
105
parent ,
112
106
null ,
113
107
false ,
114
- [ cachedFirst , cachedLast ]
108
+ nodes
115
109
)
116
110
117
111
expect ( parent . innerHTML ) . toBe ( content )
118
- expect ( first ) . toBe ( parent . firstChild )
119
- expect ( last ) . toBe ( parent . lastChild )
120
-
121
- expect ( first ) . not . toBe ( cachedFirst )
122
- expect ( last ) . not . toBe ( cachedLast )
112
+ expect ( clonedNodes [ 0 ] ) . toBe ( parent . firstChild )
113
+ expect ( clonedNodes [ clonedNodes . length - 1 ] ) . toBe ( parent . lastChild )
114
+ expect ( clonedNodes [ 0 ] ) . not . toBe ( nodes [ 0 ] )
123
115
} )
124
116
} )
125
117
} )
0 commit comments