aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2013-04-20 11:40:27 -0400
committerRichard Gibson <richard.gibson@gmail.com>2013-04-20 11:51:51 -0400
commitfb1731ab163424e22bac4372f15cda1195bfaa85 (patch)
treec1b54612ea383860694c1976ca93d79f376cf06c /test
parentd754b50cb5197a30bbdb87396b2fcfe2301b42fe (diff)
downloadjquery-fb1731ab163424e22bac4372f15cda1195bfaa85.tar.gz
jquery-fb1731ab163424e22bac4372f15cda1195bfaa85.zip
Fix #13797: .is with single-node context
(cherry picked from commit 4f786ba4d2a5544cb48f589d2659d6cab84efc34)
Diffstat (limited to 'test')
-rw-r--r--test/unit/traversing.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index d99de436a..e45ab75a5 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -141,16 +141,22 @@ test("is() with :has() selectors", function() {
});
test("is() with positional selectors", function() {
- expect(24);
-
- var isit = function(sel, match, expect) {
- equal( jQuery( sel ).is( match ), expect, "jQuery('" + sel + "').is('" + match + "')" );
- };
-
- jQuery(
- "<p id='posp'><a class='firsta' href='#'><em>first</em></a><a class='seconda' href='#'><b>test</b></a><em></em></p>"
- ).appendTo( "#qunit-fixture" );
+ expect(27);
+
+ var
+ posp = jQuery(
+ "<p id='posp'><a class='firsta' href='#'><em>first</em></a>" +
+ "<a class='seconda' href='#'><b>test</b></a><em></em></p>"
+ ).appendTo( "#qunit-fixture" ),
+ isit = function( sel, match, expect ) {
+ equal(
+ jQuery( sel ).is( match ),
+ expect,
+ "jQuery('" + sel + "').is('" + match + "')"
+ );
+ };
+ isit( "#posp", "p:last", true );
isit( "#posp", "#posp:first", true );
isit( "#posp", "#posp:eq(2)", false );
isit( "#posp", "#posp a:first", false );
@@ -179,6 +185,9 @@ test("is() with positional selectors", function() {
isit( "#posp em", "#posp a em:eq(2)", false );
ok( jQuery("#option1b").is("#select1 option:not(:first)"), "POS inside of :not() (#10970)" );
+
+ ok( jQuery( posp[0] ).is("p:last"), "context constructed from a single node (#13797)" );
+ ok( !jQuery( posp[0] ).find("#firsta").is("a:first"), "context derived from a single node (#13797)" );
});
test("index()", function() {