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

Fix for #1470 #1660

Merged
merged 5 commits into from Jun 29, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions js/jquery.mobile.listview.js
Expand Up @@ -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" );
Expand Down Expand Up @@ -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"]);
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions tests/unit/listview/index.html
Expand Up @@ -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">
Expand Down
61 changes: 53 additions & 8 deletions tests/unit/listview/listview_core.js
Expand Up @@ -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");
Expand All @@ -414,6 +459,6 @@
start();
}
]);
});
});

})(jQuery);