@@ -253,7 +253,7 @@ function pjax(options) {
253
253
254
254
// If $.pjax.defaults.version is a function, invoke it first.
255
255
// Otherwise it can be a static string.
256
- var currentVersion = ( typeof $ . pjax . defaults . version === 'function' ) ?
256
+ var currentVersion = typeof $ . pjax . defaults . version === 'function' ?
257
257
$ . pjax . defaults . version ( ) :
258
258
$ . pjax . defaults . version
259
259
@@ -299,7 +299,7 @@ function pjax(options) {
299
299
if ( blurFocus ) {
300
300
try {
301
301
document . activeElement . blur ( )
302
- } catch ( e ) { }
302
+ } catch ( e ) { /* ignore */ }
303
303
}
304
304
305
305
if ( container . title ) document . title = container . title
@@ -492,7 +492,7 @@ function onPjaxPopstate(event) {
492
492
493
493
// Force reflow/relayout before the browser tries to restore the
494
494
// scroll position.
495
- container [ 0 ] . offsetHeight
495
+ container [ 0 ] . offsetHeight // eslint-disable-line no-unused-expressions
496
496
} else {
497
497
locationReplace ( location . href )
498
498
}
@@ -566,7 +566,7 @@ function cloneContents(container) {
566
566
// Unmark script tags as already being eval'd so they can get executed again
567
567
// when restored from cache. HAXX: Uses jQuery internal method.
568
568
cloned . find ( 'script' ) . each ( function ( ) {
569
- if ( ! this . src ) jQuery . _data ( this , 'globalEval' , false )
569
+ if ( ! this . src ) $ . _data ( this , 'globalEval' , false )
570
570
} )
571
571
return cloned . contents ( )
572
572
}
@@ -665,13 +665,14 @@ function extractContainer(data, xhr, options) {
665
665
var serverUrl = xhr . getResponseHeader ( 'X-PJAX-URL' )
666
666
obj . url = serverUrl ? stripInternalParams ( parseURL ( serverUrl ) ) : options . requestUrl
667
667
668
+ var $head , $body
668
669
// Attempt to parse response html into elements
669
670
if ( fullDocument ) {
670
- var $body = $ ( parseHTML ( data . match ( / < b o d y [ ^ > ] * > ( [ \s \S . ] * ) < \/ b o d y > / i) [ 0 ] ) )
671
+ $body = $ ( parseHTML ( data . match ( / < b o d y [ ^ > ] * > ( [ \s \S . ] * ) < \/ b o d y > / i) [ 0 ] ) )
671
672
var head = data . match ( / < h e a d [ ^ > ] * > ( [ \s \S . ] * ) < \/ h e a d > / i)
672
- var $head = head != null ? $ ( parseHTML ( head [ 0 ] ) ) : $body
673
+ $head = head != null ? $ ( parseHTML ( head [ 0 ] ) ) : $body
673
674
} else {
674
- var $head = $body = $ ( parseHTML ( data ) )
675
+ $head = $body = $ ( parseHTML ( data ) )
675
676
}
676
677
677
678
// If response data is empty, return fast
@@ -683,12 +684,11 @@ function extractContainer(data, xhr, options) {
683
684
obj . title = findAll ( $head , 'title' ) . last ( ) . text ( )
684
685
685
686
if ( options . fragment ) {
687
+ var $fragment = $body
686
688
// If they specified a fragment, look for it in the response
687
689
// and pull it out.
688
- if ( options . fragment === 'body' ) {
689
- var $fragment = $body
690
- } else {
691
- var $fragment = findAll ( $body , options . fragment ) . first ( )
690
+ if ( options . fragment !== 'body' ) {
691
+ $fragment = findAll ( $fragment , options . fragment ) . first ( )
692
692
}
693
693
694
694
if ( $fragment . length ) {
@@ -797,8 +797,8 @@ function cachePop(direction, id, value) {
797
797
}
798
798
799
799
pushStack . push ( id )
800
- if ( id = popStack . pop ( ) )
801
- delete cacheMapping [ id ]
800
+ id = popStack . pop ( )
801
+ if ( id ) delete cacheMapping [ id ]
802
802
803
803
// Trim whichever stack we just pushed to to max cache length.
804
804
trimCacheStack ( pushStack , pjax . defaults . maxCacheLength )
@@ -894,6 +894,10 @@ $.support.pjax =
894
894
// pushState isn't reliable on iOS until 5.
895
895
! navigator . userAgent . match ( / ( ( i P o d | i P h o n e | i P a d ) .+ \b O S \s + [ 1 - 4 ] \D | W e b A p p s \/ .+ C F N e t w o r k ) / )
896
896
897
- $ . support . pjax ? enable ( ) : disable ( )
897
+ if ( $ . support . pjax ) {
898
+ enable ( )
899
+ } else {
900
+ disable ( )
901
+ }
898
902
899
903
} ) ( jQuery )
0 commit comments