@@ -7,7 +7,7 @@ import { objToNode } from "./fromVirtual"
7
7
8
8
const getFromRoute = (
9
9
node : Element ,
10
- route : number [ ]
10
+ route : number [ ] ,
11
11
) : Element | Text | false => {
12
12
route = route . slice ( )
13
13
while ( route . length > 0 ) {
@@ -20,15 +20,15 @@ const getFromRoute = (
20
20
export function applyDiff (
21
21
tree : Element ,
22
22
diff : diffType ,
23
- options : DiffDOMOptions // {preDiffApply, postDiffApply, textDiff, valueDiffing, _const}
23
+ options : DiffDOMOptions , // {preDiffApply, postDiffApply, textDiff, valueDiffing, _const}
24
24
) {
25
25
const action = diff [ options . _const . action ] as string | number
26
26
const route = diff [ options . _const . route ] as number [ ]
27
27
let node
28
28
29
29
if (
30
30
! [ options . _const . addElement , options . _const . addTextElement ] . includes (
31
- action
31
+ action ,
32
32
)
33
33
) {
34
34
// For adding nodes, we calculate the route later on. It's different because it includes the position of the newly added item.
@@ -56,7 +56,7 @@ export function applyDiff(
56
56
}
57
57
node . setAttribute (
58
58
diff [ options . _const . name ] as string ,
59
- diff [ options . _const . value ] as string
59
+ diff [ options . _const . value ] as string ,
60
60
)
61
61
break
62
62
case options . _const . modifyAttribute :
@@ -65,7 +65,7 @@ export function applyDiff(
65
65
}
66
66
node . setAttribute (
67
67
diff [ options . _const . name ] as string ,
68
- diff [ options . _const . newValue ] as string
68
+ diff [ options . _const . newValue ] as string ,
69
69
)
70
70
if (
71
71
checkElementType ( node , "HTMLInputElement" ) &&
@@ -88,7 +88,7 @@ export function applyDiff(
88
88
node ,
89
89
node . data ,
90
90
diff [ options . _const . oldValue ] as string ,
91
- diff [ options . _const . newValue ] as string
91
+ diff [ options . _const . newValue ] as string ,
92
92
)
93
93
if ( checkElementType ( node . parentNode , "HTMLTextAreaElement" ) ) {
94
94
node . parentNode . value = diff [ options . _const . newValue ] as string
@@ -108,7 +108,7 @@ export function applyDiff(
108
108
node ,
109
109
node . data ,
110
110
diff [ options . _const . oldValue ] as string ,
111
- diff [ options . _const . newValue ] as string
111
+ diff [ options . _const . newValue ] as string ,
112
112
)
113
113
break
114
114
case options . _const . modifyChecked :
@@ -133,19 +133,18 @@ export function applyDiff(
133
133
objToNode (
134
134
diff [ options . _const . newValue ] as nodeType ,
135
135
insideSvg ,
136
- options
136
+ options ,
137
137
) ,
138
- node
138
+ node ,
139
139
)
140
140
break
141
141
}
142
142
case options . _const . relocateGroup :
143
- nodeArray = Array (
144
- ...new Array ( diff [ options . _const . groupLength ] )
145
- ) . map ( ( ) =>
146
- node . removeChild (
147
- node . childNodes [ diff [ options . _const . from ] as number ]
148
- )
143
+ nodeArray = [ ...new Array ( diff [ options . _const . groupLength ] ) ] . map (
144
+ ( ) =>
145
+ node . removeChild (
146
+ node . childNodes [ diff [ options . _const . from ] as number ] ,
147
+ ) ,
149
148
)
150
149
nodeArray . forEach ( ( childNode , index ) => {
151
150
if ( index === 0 ) {
@@ -169,9 +168,9 @@ export function applyDiff(
169
168
objToNode (
170
169
diff [ options . _const . element ] as nodeType ,
171
170
node . namespaceURI === "http://www.w3.org/2000/svg" ,
172
- options
171
+ options ,
173
172
) ,
174
- node . childNodes [ c ] || null
173
+ node . childNodes [ c ] || null ,
175
174
)
176
175
break
177
176
}
@@ -190,7 +189,7 @@ export function applyDiff(
190
189
const parentRoute = route . slice ( )
191
190
const c : number = parentRoute . splice ( parentRoute . length - 1 , 1 ) [ 0 ]
192
191
newNode = options . document . createTextNode (
193
- diff [ options . _const . value ] as string
192
+ diff [ options . _const . value ] as string ,
194
193
)
195
194
node = getFromRoute ( tree , parentRoute )
196
195
if ( ! node . childNodes ) {
@@ -220,9 +219,9 @@ export function applyDiff(
220
219
export function applyDOM (
221
220
tree : Element ,
222
221
diffs : ( Diff | diffType ) [ ] ,
223
- options : DiffDOMOptions
222
+ options : DiffDOMOptions ,
224
223
) {
225
224
return diffs . every ( ( diff : Diff | diffType ) =>
226
- applyDiff ( tree , diff as diffType , options )
225
+ applyDiff ( tree , diff as diffType , options ) ,
227
226
)
228
227
}
0 commit comments