aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/manipulation.js
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2013-04-05 08:57:01 -0400
committerDave Methvin <dave.methvin@gmail.com>2013-04-06 16:37:32 -0400
commit1b610266502490eab42a0b9ddfac2f93da0b0fe1 (patch)
tree6588b3fcfc702725dc4fd16d7dcf0c16ff7b0396 /test/unit/manipulation.js
parent5031c9db4bf22cc04472346eeee8f25a61c5ee68 (diff)
downloadjquery-1b610266502490eab42a0b9ddfac2f93da0b0fe1.tar.gz
jquery-1b610266502490eab42a0b9ddfac2f93da0b0fe1.zip
Fix #13721. Filter before .remove() loop so positionals work. Close gh-1221.
Diffstat (limited to 'test/unit/manipulation.js')
-rw-r--r--test/unit/manipulation.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 012a0efc9..6093dbfb6 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -1713,7 +1713,8 @@ test( "clone()/html() don't expose jQuery/Sizzle expandos (#12858)", function()
});
var testRemove = function( method ) {
- var first = jQuery("#ap").children().first();
+ var markup, div,
+ first = jQuery("#ap").children().first();
first.data("foo", "bar");
@@ -1731,6 +1732,18 @@ var testRemove = function( method ) {
jQuery("#ap").children()[ method ]("a, code");
equal( jQuery("#ap").children().length, 0, "Check multi-filtered remove" );
+ // Positional and relative selectors
+ markup = "<div><span>1</span><span>2</span><span>3</span><span>4</span></div>";
+ div = jQuery( markup );
+ div.children().remove("span:nth-child(2n)");
+ equal( div.text(), "13", "relative selector in " + method );
+ div = jQuery( markup );
+ div.children().remove("span:first");
+ equal( div.text(), "234", "positional selector in " + method );
+ div = jQuery( markup );
+ div.children().remove("span:last");
+ equal( div.text(), "123", "positional selector in " + method );
+
// using contents will get comments regular, text, and comment nodes
// Handle the case where no comment is in the document
ok( jQuery("#nonnodes").contents().length >= 2, "Check node,textnode,comment remove works" );
@@ -1743,7 +1756,7 @@ var testRemove = function( method ) {
}
};
-test( "remove()", 8, function() {
+test( "remove()", 11, function() {
testRemove("remove");
});
@@ -1762,7 +1775,7 @@ test( "remove() event cleaning ", 1, function() {
cleanUp.remove();
});
-test( "detach()", 8, function() {
+test( "detach()", 11, function() {
testRemove("detach");
});