Permalink
Browse files

Merge pull request #1660 from gseguin/issue-1470

Fix for #1470
  • Loading branch information...
gseguin committed Jun 29, 2011
2 parents 595a237 + dabb66a commit d0ec1ec4520a78449bcd1c97acf0ff27e35e07e5
Showing with 67 additions and 10 deletions.
  1. +9 −2 js/jquery.mobile.listview.js
  2. +5 −0 tests/unit/listview/index.html
  3. +53 −8 tests/unit/listview/listview_core.js
@@ -47,7 +47,12 @@ $.widget( "mobile.listview", $.mobile.widget, {
});
},
_removeCorners: function( li ) {
_removeCorners: function( li, which ) {
which = which || ["top", "bottom"];
var classes = {
top: "ui-corner-top ui-corner-tr ui-corner-tl",
bottom: "ui-corner-bottom ui-corner-br ui-corner-bl"
};
li
.add( li.find(".ui-btn-inner, .ui-li-link-alt, .ui-li-thumb") )
.removeClass( "ui-corner-top ui-corner-bottom ui-corner-br ui-corner-bl ui-corner-tr ui-corner-tl" );
@@ -165,7 +170,9 @@ $.widget( "mobile.listview", $.mobile.widget, {
if(item.prev().prev().length){
self._removeCorners( item.prev() );
}
} else if (item.prev().length) {
self._removeCorners( item.prev(), ["bottom"]);
}
}
}
@@ -241,6 +241,11 @@ <h1>Split List View</h1>
</div>
</div>
<!-- Programmatically generated list items !-->
<div data-nstest-role="page" id="programmatically-generated-list">
<ul data-nstest-role="listview" data-nstest-inset="true" id="programmatically-generated-list-items"></ul>
</div>
<!-- Removing items from list -->
<div data-nstest-role="page" id='removing-items-from-list-test'>
<div data-nstest-role="header" data-nstest-position="inline">
@@ -390,15 +390,60 @@
}, 1000);
});
module("Programmatic list items manipulation");
module( "Programmatically generated list items", {
setup: function(){
var item,
data = [
{
id: 1,
label: "Item 1"
},
{
id: 2,
label: "Item 2"
},
{
id: 3,
label: "Item 3"
},
{
id: 4,
label: "Item 4"
}
];
$( "#programmatically-generated-list-items" ).html("");
for ( var i = 0, len = data.length; i < len; i++ ) {
item = $( '<li id="myItem' + data[i].id + '">' );
label = $( "<strong>" + data[i].label + "</strong>").appendTo( item );
$( "#programmatically-generated-list-items" ).append( item );
}
}
});
asyncTest( "Removing list items", 4, function() {
$.testHelper.pageSequence([
function(){
$.testHelper.openPage("#removing-items-from-list-test");
},
asyncTest( "Corner styling on programmatically created list items", function() {
// https://github.com/jquery/jquery-mobile/issues/1470
$.testHelper.pageSequence([
function() {
$.testHelper.openPage( "#programmatically-generated-list" );
},
function() {
ok(!$( "#programmatically-generated-list-items li:first-child" ).hasClass( "ui-corner-bottom" ), "First list item should not have class ui-corner-bottom" );
start();
}
]);
});
module("Programmatic list items manipulation");
function(){
asyncTest("Removing list items", 4, function() {
$.testHelper.pageSequence([
function() {
$.testHelper.openPage("#removing-items-from-list-test");
},
function() {
var ul = $('#removing-items-from-list-test ul');
ul.find("li").first().remove();
equal(ul.find("li").length, 3, "There should be only 3 list items left");
@@ -414,6 +459,6 @@
start();
}
]);
});
});
})(jQuery);

0 comments on commit d0ec1ec

Please sign in to comment.