Skip to content
This repository
Browse code

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
Mat Marquis authored

Showing 1 changed file with 2 additions and 4 deletions. Show diff stats Hide diff stats

  1. 6  js/widgets/fixedToolbar.js
6  js/widgets/fixedToolbar.js
@@ -149,10 +149,8 @@ define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.core", "../jque
149 149
 					if ( o.trackPersistentToolbars ) {
150 150
 						var thisFooter = $( ".ui-footer-fixed:jqmData(id)", this ),
151 151
 							thisHeader = $( ".ui-header-fixed:jqmData(id)", this ),
152  
-							nextFooter = thisFooter.length && ui.nextPage && $( ".ui-footer-fixed:jqmData(id='" + thisFooter.jqmData( "id" ) + "')", ui.nextPage ),
153  
-							nextHeader = thisHeader.length && ui.nextPage && $( ".ui-header-fixed:jqmData(id='" + thisHeader.jqmData( "id" ) + "')", ui.nextPage );
154  
-
155  
-						nextFooter = nextFooter || $();
  152
+							nextFooter = thisFooter.length && ui.nextPage && $( ".ui-footer-fixed:jqmData(id='" + thisFooter.jqmData( "id" ) + "')", ui.nextPage ) || $(),
  153
+							nextHeader = thisHeader.length && ui.nextPage && $( ".ui-header-fixed:jqmData(id='" + thisHeader.jqmData( "id" ) + "')", ui.nextPage ) || $();
156 154
 
157 155
 							if ( nextFooter.length || nextHeader.length ) {
158 156
 

2 notes on commit 5a6b2c3

John Bender

@Wilto

Won't:

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

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

Graham Gilchrist

@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.