@@ -7,7 +7,7 @@ import { objToNode } from "./fromVirtual"
77
88const getFromRoute = (
99 node : Element ,
10- route : number [ ]
10+ route : number [ ] ,
1111) : Element | Text | false => {
1212 route = route . slice ( )
1313 while ( route . length > 0 ) {
@@ -20,15 +20,15 @@ const getFromRoute = (
2020export function applyDiff (
2121 tree : Element ,
2222 diff : diffType ,
23- options : DiffDOMOptions // {preDiffApply, postDiffApply, textDiff, valueDiffing, _const}
23+ options : DiffDOMOptions , // {preDiffApply, postDiffApply, textDiff, valueDiffing, _const}
2424) {
2525 const action = diff [ options . _const . action ] as string | number
2626 const route = diff [ options . _const . route ] as number [ ]
2727 let node
2828
2929 if (
3030 ! [ options . _const . addElement , options . _const . addTextElement ] . includes (
31- action
31+ action ,
3232 )
3333 ) {
3434 // 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(
5656 }
5757 node . setAttribute (
5858 diff [ options . _const . name ] as string ,
59- diff [ options . _const . value ] as string
59+ diff [ options . _const . value ] as string ,
6060 )
6161 break
6262 case options . _const . modifyAttribute :
@@ -65,7 +65,7 @@ export function applyDiff(
6565 }
6666 node . setAttribute (
6767 diff [ options . _const . name ] as string ,
68- diff [ options . _const . newValue ] as string
68+ diff [ options . _const . newValue ] as string ,
6969 )
7070 if (
7171 checkElementType ( node , "HTMLInputElement" ) &&
@@ -88,7 +88,7 @@ export function applyDiff(
8888 node ,
8989 node . data ,
9090 diff [ options . _const . oldValue ] as string ,
91- diff [ options . _const . newValue ] as string
91+ diff [ options . _const . newValue ] as string ,
9292 )
9393 if ( checkElementType ( node . parentNode , "HTMLTextAreaElement" ) ) {
9494 node . parentNode . value = diff [ options . _const . newValue ] as string
@@ -108,7 +108,7 @@ export function applyDiff(
108108 node ,
109109 node . data ,
110110 diff [ options . _const . oldValue ] as string ,
111- diff [ options . _const . newValue ] as string
111+ diff [ options . _const . newValue ] as string ,
112112 )
113113 break
114114 case options . _const . modifyChecked :
@@ -133,19 +133,18 @@ export function applyDiff(
133133 objToNode (
134134 diff [ options . _const . newValue ] as nodeType ,
135135 insideSvg ,
136- options
136+ options ,
137137 ) ,
138- node
138+ node ,
139139 )
140140 break
141141 }
142142 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+ ) ,
149148 )
150149 nodeArray . forEach ( ( childNode , index ) => {
151150 if ( index === 0 ) {
@@ -169,9 +168,9 @@ export function applyDiff(
169168 objToNode (
170169 diff [ options . _const . element ] as nodeType ,
171170 node . namespaceURI === "http://www.w3.org/2000/svg" ,
172- options
171+ options ,
173172 ) ,
174- node . childNodes [ c ] || null
173+ node . childNodes [ c ] || null ,
175174 )
176175 break
177176 }
@@ -190,7 +189,7 @@ export function applyDiff(
190189 const parentRoute = route . slice ( )
191190 const c : number = parentRoute . splice ( parentRoute . length - 1 , 1 ) [ 0 ]
192191 newNode = options . document . createTextNode (
193- diff [ options . _const . value ] as string
192+ diff [ options . _const . value ] as string ,
194193 )
195194 node = getFromRoute ( tree , parentRoute )
196195 if ( ! node . childNodes ) {
@@ -220,9 +219,9 @@ export function applyDiff(
220219export function applyDOM (
221220 tree : Element ,
222221 diffs : ( Diff | diffType ) [ ] ,
223- options : DiffDOMOptions
222+ options : DiffDOMOptions ,
224223) {
225224 return diffs . every ( ( diff : Diff | diffType ) =>
226- applyDiff ( tree , diff as diffType , options )
225+ applyDiff ( tree , diff as diffType , options ) ,
227226 )
228227}
0 commit comments