Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #4887 - Prevents `0` from being appended to the document when u…

…sing a persistent footer with jQuery 1.8.0.
  • Loading branch information...
commit 5a6b2c3acfc72de4d0ae773ed0e076ef37bac1a5 1 parent 7f312da
@Wilto Wilto authored
Showing with 2 additions and 4 deletions.
  1. +2 −4 js/widgets/fixedToolbar.js
View
6 js/widgets/fixedToolbar.js
@@ -149,10 +149,8 @@ define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.core", "../jque
if ( o.trackPersistentToolbars ) {
var thisFooter = $( ".ui-footer-fixed:jqmData(id)", this ),
thisHeader = $( ".ui-header-fixed:jqmData(id)", this ),
- nextFooter = thisFooter.length && ui.nextPage && $( ".ui-footer-fixed:jqmData(id='" + thisFooter.jqmData( "id" ) + "')", ui.nextPage ),
- nextHeader = thisHeader.length && ui.nextPage && $( ".ui-header-fixed:jqmData(id='" + thisHeader.jqmData( "id" ) + "')", ui.nextPage );
-
- nextFooter = nextFooter || $();
+ nextFooter = thisFooter.length && ui.nextPage && $( ".ui-footer-fixed:jqmData(id='" + thisFooter.jqmData( "id" ) + "')", ui.nextPage ) || $(),
+ nextHeader = thisHeader.length && ui.nextPage && $( ".ui-header-fixed:jqmData(id='" + thisHeader.jqmData( "id" ) + "')", ui.nextPage ) || $();
if ( nextFooter.length || nextHeader.length ) {

2 comments on commit 5a6b2c3

@johnbender

@Wilto

Won't:

ui.nextPage && $( ".ui-header-fixed:jqmData(id='" + thisHeader.jqmData( "id" ) + "')", ui.nextPage )

Result in an empty set making the || $() unnecessary?

@grahamgilchrist

@johnbender With jQuery 1.8.0, leaving out the || $() means that nextFooter and nextHeader had values of 0 when there are no header or footer elements present.
When the two are added together later and appended to the document using nextFooter.add( nextHeader ).appendTo( $.mobile.pageContainer ); this results in an array with the empty footer object and a zero being appended to the document. This then appends unwanted text elements consisting of zeroes in the document body.
Adding the || $() turns nextHeader from a literal zero value into an empty jQuery object which doesn't mess with the DOM when appended.

For more info see the test case at: #4887

Please sign in to comment.
Something went wrong with that request. Please try again.