Permalink
Browse files

Toolbar: Only initialize this.pagecontainer if the toolbar is fixed

Fixes gh-7839
Closes gh-7860
  • Loading branch information...
gabrielschulhof committed Nov 29, 2014
1 parent 6f3ab5a commit 0d533e05c0645600cbd6067402fd5ef813bb9d49
@@ -35,8 +35,8 @@ define( [ "jquery", "../widget", "../core", "../animationComplete", "../navigati
_create: function() {
this._super();
this.pagecontainer = $( ":mobile-pagecontainer" );
if ( this.options.position === "fixed" && !this.options.supportBlacklist() ) {
this.pagecontainer = this.element.closest( ".ui-mobile-viewport" );
this._makeFixed();
}
},
@@ -0,0 +1,46 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>jQuery Mobile Toolbar Test Suite</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="../../../external/requirejs/require.js"></script>
<script src="../../../js/requirejs.config.js"></script>
<script src="../../../js/jquery.tag.inserter.js"></script>
<script src="../../jquery.setNameSpace.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>
<script src="../../../external/qunit/qunit.js"></script>
<script>
$.testHelper.asyncLoad([
[
"navigation/method",
"widgets/fixedToolbar",
],
[ "init"],
[ "./fixed_toolbar_core.js" ]
]);
</script>
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/>
<link rel="stylesheet" href="../../jqm-tests.css"/>
<script src="../../swarminject.js"></script>
</head>
<body>
<div id="qunit"></div>
<div data-nstest-role="page" id="default">
<div data-nstest-role="header" id="testHeader">
<h1>Header</h1>
</div>
<div class="ui-content">
<p>Content</p>
</div>
<div data-nstest-role="footer" data-nstest-position="fixed" id="testFooter">
<h1>Footer</h1>
</div>
</div>
</body>
</html>
@@ -0,0 +1,8 @@
// Establishing the page container for a toolbar reduces performance and is only needed for fixed
// toolbars (https://github.com/jquery/jquery-mobile/issues/7839)
test( "Static toolbar does not have 'pagecontainer' instance variable", function() {
deepEqual( !!$( "#testHeader" ).data( "mobile-toolbar" ).pagecontainer, false,
"Static toolbar does not have 'pagecontainer' instance variable" );
deepEqual( !!$( "#testFooter" ).data( "mobile-toolbar" ).pagecontainer, true,
"Fixed toolbar has 'pagecontainer' instance variable" );
});

0 comments on commit 0d533e0

Please sign in to comment.