Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Using a persistent footer with jQuery 1.8.0 adds Zeros to end of document #4887

@grahamgilchrist

Description

@grahamgilchrist

Issue description

When using jQuery 1.8.0, in a site with a persistent footer toolbar containing a navbar, and no persistent header, extra text elements containing zeroes are being added to the end of the DOM whenever the page is changed through the footer navbar. This issue does not exist with jQuery 1.7.2

Persistent footer docs:
http://jquerymobile.com/demos/1.1.1/docs/toolbars/footer-persist-a.html

I've traced the problem to the file js/widgets/fixedToolbar.js, line 155:
https://github.com/jquery/jquery-mobile/blob/master/js/widgets/fixedToolbar.js#L155

At this point, if there is no persistent header, the variable nextHeader has a value of 0. On line 159, nextFooter.add( nextHeader ) produces an array containing the footer jQ object and a value of zero. In jQuery 1.7.2, when appended to the document, the 0 is ignored. in jQuery 1.8.0, it is added as a text element.

It could be argued this is a bug with jQuery, but it seems like there might be a line missing which would fix this very easily. We already assign nextFooter to an empty jQ object if it is blank, so we could add the same for nextHeader after line 155:
nextHeader = nextHeader || $();

So the code would look like

...
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 || $();
                        nextHeader = nextHeader || $();

                            if ( nextFooter.length || nextHeader.length ) {
...

Sample page using the jsbin template which uses latest code

http://jsbin.com/orucec/111/

Use the footer tabs in the output window to switch pages. Notice zeroes being added to the document. Uncomment the jQuery 1.7.2 script tag in the HTML header and remove the jQuery 1.8.0 script tag. Try the tabs again. The problem no longer occurs.

Steps to reproduce

  • Create a new jQuery mobile project using jQuery mobile 1.1.1 and jQuery 1.8.0
  • Add two pages to the project with header and footer regions using data-role="header"
  • Add data-id="test-footer" data-position="fixed" to the data-role footer element
  • Add a navbar list data-role="navbar" inside the footer and add list items with links to the two pages
  • Load the page and navigate between the two pages.

For more info see the JSBin example above.

Expected outcome

The fixed footer should stay in place while the page transitions behind it. Once the transition is complete, the target page should be rendered.

Actual outcome

The fixed footer stays in place, and the transition happens, but during the transition, extra text elements are added to the page.

Query Mobile version

Mobile: 1.1.1
jQuery: 1.8.0

Browsers/platforms tested

Problem in:
Webkit:

  • Safari 5.0
  • Safari iOS 5.1
    Does not occur in:
  • Firefox 8.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions