@@ -9,7 +9,10 @@ function morphAttrs(fromNode, toNode) {
99 var fromValue ;
1010
1111 // document-fragments dont have attributes so lets not do anything
12- if ( toNode . nodeType === DOCUMENT_FRAGMENT_NODE || fromNode . nodeType === DOCUMENT_FRAGMENT_NODE ) {
12+ if (
13+ toNode . nodeType === DOCUMENT_FRAGMENT_NODE ||
14+ fromNode . nodeType === DOCUMENT_FRAGMENT_NODE
15+ ) {
1316 return ;
1417 }
1518
@@ -25,7 +28,7 @@ function morphAttrs(fromNode, toNode) {
2528 fromValue = fromNode . getAttributeNS ( attrNamespaceURI , attrName ) ;
2629
2730 if ( fromValue !== attrValue ) {
28- if ( attr . prefix === ' xmlns' ) {
31+ if ( attr . prefix === " xmlns" ) {
2932 attrName = attr . name ; // It's not allowed to set an attribute with the XMLNS namespace without specifying the `xmlns` prefix
3033 }
3134 fromNode . setAttributeNS ( attrNamespaceURI , attrName , attrValue ) ;
@@ -63,14 +66,15 @@ function morphAttrs(fromNode, toNode) {
6366}
6467
6568var range ; // Create a range object for efficently rendering strings to elements.
66- var NS_XHTML = ' http://www.w3.org/1999/xhtml' ;
69+ var NS_XHTML = " http://www.w3.org/1999/xhtml" ;
6770
68- var doc = typeof document === 'undefined' ? undefined : document ;
69- var HAS_TEMPLATE_SUPPORT = ! ! doc && 'content' in doc . createElement ( 'template' ) ;
70- var HAS_RANGE_SUPPORT = ! ! doc && doc . createRange && 'createContextualFragment' in doc . createRange ( ) ;
71+ var doc = typeof document === "undefined" ? undefined : document ;
72+ var HAS_TEMPLATE_SUPPORT = ! ! doc && "content" in doc . createElement ( "template" ) ;
73+ var HAS_RANGE_SUPPORT =
74+ ! ! doc && doc . createRange && "createContextualFragment" in doc . createRange ( ) ;
7175
7276function createFragmentFromTemplate ( str ) {
73- var template = doc . createElement ( ' template' ) ;
77+ var template = doc . createElement ( " template" ) ;
7478 template . innerHTML = str ;
7579 return template . content . childNodes [ 0 ] ;
7680}
@@ -86,7 +90,7 @@ function createFragmentFromRange(str) {
8690}
8791
8892function createFragmentFromWrap ( str ) {
89- var fragment = doc . createElement ( ' body' ) ;
93+ var fragment = doc . createElement ( " body" ) ;
9094 fragment . innerHTML = str ;
9195 return fragment . childNodes [ 0 ] ;
9296}
@@ -139,9 +143,11 @@ function compareNodeNames(fromEl, toEl) {
139143 // need to normalize the tag name before comparing. Normal HTML elements that are
140144 // in the "http://www.w3.org/1999/xhtml"
141145 // are converted to upper case
142- if ( fromCodeStart <= 90 && toCodeStart >= 97 ) { // from is upper and to is lower
146+ if ( fromCodeStart <= 90 && toCodeStart >= 97 ) {
147+ // from is upper and to is lower
143148 return fromNodeName === toNodeName . toUpperCase ( ) ;
144- } else if ( toCodeStart <= 90 && fromCodeStart >= 97 ) { // to is upper and from is lower
149+ } else if ( toCodeStart <= 90 && fromCodeStart >= 97 ) {
150+ // to is upper and from is lower
145151 return toNodeName === fromNodeName . toUpperCase ( ) ;
146152 } else {
147153 return false ;
@@ -158,9 +164,9 @@ function compareNodeNames(fromEl, toEl) {
158164 * @return {Element }
159165 */
160166function createElementNS ( name , namespaceURI ) {
161- return ! namespaceURI || namespaceURI === NS_XHTML ?
162- doc . createElement ( name ) :
163- doc . createElementNS ( namespaceURI , name ) ;
167+ return ! namespaceURI || namespaceURI === NS_XHTML
168+ ? doc . createElement ( name )
169+ : doc . createElementNS ( namespaceURI , name ) ;
164170}
165171
166172/**
@@ -180,7 +186,7 @@ function syncBooleanAttrProp(fromEl, toEl, name) {
180186 if ( fromEl [ name ] !== toEl [ name ] ) {
181187 fromEl [ name ] = toEl [ name ] ;
182188 if ( fromEl [ name ] ) {
183- fromEl . setAttribute ( name , '' ) ;
189+ fromEl . setAttribute ( name , "" ) ;
184190 } else {
185191 fromEl . removeAttribute ( name ) ;
186192 }
@@ -192,25 +198,25 @@ var specialElHandlers = {
192198 var parentNode = fromEl . parentNode ;
193199 if ( parentNode ) {
194200 var parentName = parentNode . nodeName . toUpperCase ( ) ;
195- if ( parentName === ' OPTGROUP' ) {
201+ if ( parentName === " OPTGROUP" ) {
196202 parentNode = parentNode . parentNode ;
197203 parentName = parentNode && parentNode . nodeName . toUpperCase ( ) ;
198204 }
199- if ( parentName === ' SELECT' && ! parentNode . hasAttribute ( ' multiple' ) ) {
200- if ( fromEl . hasAttribute ( ' selected' ) && ! toEl . selected ) {
205+ if ( parentName === " SELECT" && ! parentNode . hasAttribute ( " multiple" ) ) {
206+ if ( fromEl . hasAttribute ( " selected" ) && ! toEl . selected ) {
201207 // Workaround for MS Edge bug where the 'selected' attribute can only be
202208 // removed if set to a non-empty value:
203209 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12087679/
204- fromEl . setAttribute ( ' selected' , ' selected' ) ;
205- fromEl . removeAttribute ( ' selected' ) ;
210+ fromEl . setAttribute ( " selected" , " selected" ) ;
211+ fromEl . removeAttribute ( " selected" ) ;
206212 }
207213 // We have to reset select element's selectedIndex to -1, otherwise setting
208214 // fromEl.selected using the syncBooleanAttrProp below has no effect.
209215 // The correct selectedIndex will be set in the SELECT special handler below.
210216 parentNode . selectedIndex = - 1 ;
211217 }
212218 }
213- syncBooleanAttrProp ( fromEl , toEl , ' selected' ) ;
219+ syncBooleanAttrProp ( fromEl , toEl , " selected" ) ;
214220 } ,
215221 /**
216222 * The "value" attribute is special for the <input> element since it sets
@@ -219,15 +225,15 @@ var specialElHandlers = {
219225 * initial value. Similar for the "checked" attribute, and "disabled".
220226 */
221227 INPUT : function ( fromEl , toEl ) {
222- syncBooleanAttrProp ( fromEl , toEl , ' checked' ) ;
223- syncBooleanAttrProp ( fromEl , toEl , ' disabled' ) ;
228+ syncBooleanAttrProp ( fromEl , toEl , " checked" ) ;
229+ syncBooleanAttrProp ( fromEl , toEl , " disabled" ) ;
224230
225231 if ( fromEl . value !== toEl . value ) {
226232 fromEl . value = toEl . value ;
227233 }
228234
229- if ( ! toEl . hasAttribute ( ' value' ) ) {
230- fromEl . removeAttribute ( ' value' ) ;
235+ if ( ! toEl . hasAttribute ( " value" ) ) {
236+ fromEl . removeAttribute ( " value" ) ;
231237 }
232238 } ,
233239
@@ -243,15 +249,18 @@ var specialElHandlers = {
243249 // node value and vise versa. This ignores an empty update.
244250 var oldValue = firstChild . nodeValue ;
245251
246- if ( oldValue == newValue || ( ! newValue && oldValue == fromEl . placeholder ) ) {
252+ if (
253+ oldValue == newValue ||
254+ ( ! newValue && oldValue == fromEl . placeholder )
255+ ) {
247256 return ;
248257 }
249258
250259 firstChild . nodeValue = newValue ;
251260 }
252261 } ,
253262 SELECT : function ( fromEl , toEl ) {
254- if ( ! toEl . hasAttribute ( ' multiple' ) ) {
263+ if ( ! toEl . hasAttribute ( " multiple" ) ) {
255264 var selectedIndex = - 1 ;
256265 var i = 0 ;
257266 // We have to loop through children of fromEl, not toEl since nodes can be moved
@@ -263,12 +272,12 @@ var specialElHandlers = {
263272 var nodeName ;
264273 while ( curChild ) {
265274 nodeName = curChild . nodeName && curChild . nodeName . toUpperCase ( ) ;
266- if ( nodeName === ' OPTGROUP' ) {
275+ if ( nodeName === " OPTGROUP" ) {
267276 optgroup = curChild ;
268277 curChild = optgroup . firstChild ;
269278 } else {
270- if ( nodeName === ' OPTION' ) {
271- if ( curChild . hasAttribute ( ' selected' ) ) {
279+ if ( nodeName === " OPTION" ) {
280+ if ( curChild . hasAttribute ( " selected" ) ) {
272281 selectedIndex = i ;
273282 break ;
274283 }
@@ -284,33 +293,36 @@ var specialElHandlers = {
284293
285294 fromEl . selectedIndex = selectedIndex ;
286295 }
287- }
296+ } ,
288297} ;
289298
290299var ELEMENT_NODE = 1 ;
291300var DOCUMENT_FRAGMENT_NODE$1 = 11 ;
292301var TEXT_NODE = 3 ;
293302var COMMENT_NODE = 8 ;
294303
295- function noop ( ) { }
304+ function noop ( ) { }
296305
297306function defaultGetNodeKey ( node ) {
298307 if ( node ) {
299- return ( node . getAttribute && node . getAttribute ( 'id' ) ) || node . id ;
308+ return ( node . getAttribute && node . getAttribute ( "id" ) ) || node . id ;
300309 }
301310}
302311
303312function morphdomFactory ( morphAttrs ) {
304-
305313 return function morphdom ( fromNode , toNode , options ) {
306314 if ( ! options ) {
307315 options = { } ;
308316 }
309317
310- if ( typeof toNode === 'string' ) {
311- if ( fromNode . nodeName === '#document' || fromNode . nodeName === 'HTML' || fromNode . nodeName === 'BODY' ) {
318+ if ( typeof toNode === "string" ) {
319+ if (
320+ fromNode . nodeName === "#document" ||
321+ fromNode . nodeName === "HTML" ||
322+ fromNode . nodeName === "BODY"
323+ ) {
312324 var toNodeHtml = toNode ;
313- toNode = doc . createElement ( ' html' ) ;
325+ toNode = doc . createElement ( " html" ) ;
314326 toNode . innerHTML = toNodeHtml ;
315327 } else {
316328 toNode = toElement ( toNode ) ;
@@ -339,7 +351,6 @@ function morphdomFactory(morphAttrs) {
339351 if ( node . nodeType === ELEMENT_NODE ) {
340352 var curChild = node . firstChild ;
341353 while ( curChild ) {
342-
343354 var key = undefined ;
344355
345356 if ( skipKeyedNodes && ( key = getNodeKey ( curChild ) ) ) {
@@ -411,7 +422,10 @@ function morphdomFactory(morphAttrs) {
411422 // }
412423
413424 function indexTree ( node ) {
414- if ( node . nodeType === ELEMENT_NODE || node . nodeType === DOCUMENT_FRAGMENT_NODE$1 ) {
425+ if (
426+ node . nodeType === ELEMENT_NODE ||
427+ node . nodeType === DOCUMENT_FRAGMENT_NODE$1
428+ ) {
415429 var curChild = node . firstChild ;
416430 while ( curChild ) {
417431 var key = getNodeKey ( curChild ) ;
@@ -501,7 +515,7 @@ function morphdomFactory(morphAttrs) {
501515 }
502516 }
503517
504- if ( fromEl . nodeName !== ' TEXTAREA' ) {
518+ if ( fromEl . nodeName !== " TEXTAREA" ) {
505519 morphChildren ( fromEl , toEl ) ;
506520 } else {
507521 if ( fromEl . innerHTML != toEl . innerHTML ) {
@@ -532,7 +546,10 @@ function morphdomFactory(morphAttrs) {
532546 while ( curFromNodeChild ) {
533547 fromNextSibling = curFromNodeChild . nextSibling ;
534548
535- if ( curToNodeChild . isSameNode && curToNodeChild . isSameNode ( curFromNodeChild ) ) {
549+ if (
550+ curToNodeChild . isSameNode &&
551+ curToNodeChild . isSameNode ( curFromNodeChild )
552+ ) {
536553 curToNodeChild = toNextSibling ;
537554 curFromNodeChild = fromNextSibling ;
538555 continue outer;
@@ -583,7 +600,11 @@ function morphdomFactory(morphAttrs) {
583600 } else {
584601 // NOTE: we skip nested keyed nodes from being removed since there is
585602 // still a chance they will be matched up later
586- removeNode ( curFromNodeChild , fromEl , true /* skip keyed nodes */ ) ;
603+ removeNode (
604+ curFromNodeChild ,
605+ fromEl ,
606+ true /* skip keyed nodes */
607+ ) ;
587608 }
588609
589610 curFromNodeChild = matchingFromEl ;
@@ -599,24 +620,27 @@ function morphdomFactory(morphAttrs) {
599620 isCompatible = false ;
600621 }
601622
602- isCompatible = isCompatible !== false && compareNodeNames ( curFromNodeChild , curToNodeChild ) ;
623+ isCompatible =
624+ isCompatible !== false &&
625+ compareNodeNames ( curFromNodeChild , curToNodeChild ) ;
603626 if ( isCompatible ) {
604627 // We found compatible DOM elements so transform
605628 // the current "from" node to match the current
606629 // target DOM node.
607630 // MORPH
608631 morphEl ( curFromNodeChild , curToNodeChild ) ;
609632 }
610-
611- } else if ( curFromNodeType === TEXT_NODE || curFromNodeType == COMMENT_NODE ) {
633+ } else if (
634+ curFromNodeType === TEXT_NODE ||
635+ curFromNodeType == COMMENT_NODE
636+ ) {
612637 // Both nodes being compared are Text or Comment nodes
613638 isCompatible = true ;
614639 // Simply update nodeValue on the original node to
615640 // change the text value
616641 if ( curFromNodeChild . nodeValue !== curToNodeChild . nodeValue ) {
617642 curFromNodeChild . nodeValue = curToNodeChild . nodeValue ;
618643 }
619-
620644 }
621645 }
622646
@@ -651,7 +675,11 @@ function morphdomFactory(morphAttrs) {
651675 // our "to node" and we exhausted all of the children "from"
652676 // nodes. Therefore, we will just append the current "to" node
653677 // to the end
654- if ( curToNodeKey && ( matchingFromEl = fromNodesLookup [ curToNodeKey ] ) && compareNodeNames ( matchingFromEl , curToNodeChild ) ) {
678+ if (
679+ curToNodeKey &&
680+ ( matchingFromEl = fromNodesLookup [ curToNodeKey ] ) &&
681+ compareNodeNames ( matchingFromEl , curToNodeChild )
682+ ) {
655683 fromEl . appendChild ( matchingFromEl ) ;
656684 // MORPH
657685 morphEl ( matchingFromEl , curToNodeChild ) ;
@@ -663,7 +691,9 @@ function morphdomFactory(morphAttrs) {
663691 }
664692
665693 if ( curToNodeChild . actualize ) {
666- curToNodeChild = curToNodeChild . actualize ( fromEl . ownerDocument || doc ) ;
694+ curToNodeChild = curToNodeChild . actualize (
695+ fromEl . ownerDocument || doc
696+ ) ;
667697 }
668698 fromEl . appendChild ( curToNodeChild ) ;
669699 handleNodeAdded ( curToNodeChild ) ;
@@ -693,13 +723,20 @@ function morphdomFactory(morphAttrs) {
693723 if ( toNodeType === ELEMENT_NODE ) {
694724 if ( ! compareNodeNames ( fromNode , toNode ) ) {
695725 onNodeDiscarded ( fromNode ) ;
696- morphedNode = moveChildren ( fromNode , createElementNS ( toNode . nodeName , toNode . namespaceURI ) ) ;
726+ morphedNode = moveChildren (
727+ fromNode ,
728+ createElementNS ( toNode . nodeName , toNode . namespaceURI )
729+ ) ;
697730 }
698731 } else {
699732 // Going from an element node to a text node
700733 morphedNode = toNode ;
701734 }
702- } else if ( morphedNodeType === TEXT_NODE || morphedNodeType === COMMENT_NODE ) { // Text or comment node
735+ } else if (
736+ morphedNodeType === TEXT_NODE ||
737+ morphedNodeType === COMMENT_NODE
738+ ) {
739+ // Text or comment node
703740 if ( toNodeType === morphedNodeType ) {
704741 if ( morphedNode . nodeValue !== toNode . nodeValue ) {
705742 morphedNode . nodeValue = toNode . nodeValue ;
0 commit comments