@@ -85,15 +85,16 @@ const createKeepAliveManager = () => {
8585 // set global options: { deactivateDelay, keepInactiveCount, limit }
8686 setOptions : ( opts = { } ) => {
8787 if ( typeof opts . deactivateDelay === 'number' ) deactivateDelay = opts . deactivateDelay
88- if ( typeof opts . keepInactiveCount === 'number' )
88+ if ( typeof opts . keepInactiveCount === 'number' ) {
8989 keepInactiveCount = Math . max ( 0 , Math . floor ( opts . keepInactiveCount ) )
90+ }
9091 if ( typeof opts . limit === 'number' ) limit = Math . max ( 0 , Math . floor ( opts . limit ) )
9192 } ,
9293 register : ( id , opts ) => {
9394 // opts: { setShouldRender, persistOnUnmount }
9495 instances . set ( id , {
9596 setShouldRender : opts . setShouldRender ,
96- persistOnUnmount : ! ! opts . persistOnUnmount ,
97+ persistOnUnmount : ! ! opts . persistOnUnmount
9798 } )
9899 } ,
99100 unregister : ( id ) => {
@@ -193,7 +194,7 @@ const createKeepAliveManager = () => {
193194 instances . delete ( id )
194195 activeMap . delete ( id )
195196 keys = keys . filter ( ( k ) => k !== id )
196- } ,
197+ }
197198 }
198199}
199200
@@ -236,7 +237,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
236237 const effectivePersist = ActivityComponent ? true : persistOnUnmount
237238 keepAliveManager . register ( id , {
238239 setShouldRender,
239- persistOnUnmount : effectivePersist ,
240+ persistOnUnmount : effectivePersist
240241 } )
241242 }
242243 return ( ) => {
@@ -329,14 +330,14 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
329330 if ( ! active ) return
330331 scrollPos . current . set ( e . target , {
331332 left : e . target . scrollLeft ,
332- top : e . target . scrollTop ,
333+ top : e . target . scrollTop
333334 } )
334335 }
335336
336337 // Capture scroll events to record positions
337338 target . addEventListener ( 'scroll' , onScroll , {
338339 capture : true ,
339- passive : true ,
340+ passive : true
340341 } )
341342
342343 return ( ) => {
@@ -390,7 +391,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
390391 // 在移动 DOM 之前,发送自定义事件通知子组件,然后同步移动到占位符下。
391392 // 之前使用短延迟的异步移动会导致渲染滞后和大量定时器/帧回调,移到同步移动以提升响应性。
392393 const event = new CustomEvent ( 'keepalive-dom-move' , {
393- detail : { from : container . parentNode , to : placeholder } ,
394+ detail : { from : container . parentNode , to : placeholder }
394395 } )
395396
396397 let dispatchError = null
@@ -405,7 +406,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
405406 console . debug ( '[KeepAlive] appending container to placeholder' , id , {
406407 from : container . parentNode ,
407408 to : placeholder ,
408- dispatchError,
409+ dispatchError
409410 } )
410411 } catch ( e ) { }
411412 }
@@ -428,7 +429,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
428429 id,
429430 note : 'no-children-after-append' ,
430431 childElementCount : container . childElementCount ,
431- time : Date . now ( ) ,
432+ time : Date . now ( )
432433 } )
433434 try {
434435 document . body . dataset . keepaliveIssue = 'no-children'
@@ -454,7 +455,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
454455 childElementCount : container . childElementCount ,
455456 appended,
456457 dispatchError,
457- time : Date . now ( ) ,
458+ time : Date . now ( )
458459 } )
459460 }
460461 } catch ( e ) { }
@@ -492,7 +493,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
492493 note : 'cleared-inline-display-none' ,
493494 clearedCount : cleared . length ,
494495 clearedTagsSample : cleared . slice ( 0 , 5 ) ,
495- time : Date . now ( ) ,
496+ time : Date . now ( )
496497 } )
497498 }
498499 } catch ( e ) { }
@@ -523,7 +524,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
523524 window . __keepalive_debug_details . push ( {
524525 id,
525526 note : 'force-visible-root' ,
526- time : Date . now ( ) ,
527+ time : Date . now ( )
527528 } )
528529 }
529530 }
@@ -555,7 +556,7 @@ const KeepAlive = ({ id, active = false, children, persistOnUnmount = false, cac
555556 shouldRender,
556557 containerNode : ! ! containerNode ,
557558 childrenType : typeof children ,
558- time : Date . now ( ) ,
559+ time : Date . now ( )
559560 } )
560561 } catch ( e ) { }
561562 } , [ shouldRender , active , containerNode , id , children ] )
@@ -613,7 +614,7 @@ KeepAlive.propTypes = {
613614 active : PropTypes . bool ,
614615 children : PropTypes . node ,
615616 persistOnUnmount : PropTypes . bool ,
616- cacheLimit : PropTypes . number ,
617+ cacheLimit : PropTypes . number
617618}
618619
619620export default KeepAlive
0 commit comments