CHILD positions were being cached improperly. Tweaked it and added a test to make sure it doesn't happen again. Fixes jQuery bug #3924.
This commit is contained in:
parent
00b70c7527
commit
626961c4a5
|
@ -495,7 +495,7 @@ var Expr = Sizzle.selectors = {
|
||||||
CHILD: function(elem, match){
|
CHILD: function(elem, match){
|
||||||
var type = match[1], parent = elem.parentNode;
|
var type = match[1], parent = elem.parentNode;
|
||||||
|
|
||||||
var doneName = "child" + parent.childNodes.length;
|
var doneName = match[0];
|
||||||
|
|
||||||
if ( parent && (!parent[ doneName ] || !elem.nodeIndex) ) {
|
if ( parent && (!parent[ doneName ] || !elem.nodeIndex) ) {
|
||||||
var count = 1;
|
var count = 1;
|
||||||
|
|
|
@ -141,7 +141,7 @@ test("multiple", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("child and adjacent", function() {
|
test("child and adjacent", function() {
|
||||||
expect(44);
|
expect(45);
|
||||||
t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
|
t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
|
||||||
t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
|
t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
|
||||||
t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
|
t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
|
||||||
|
@ -169,6 +169,14 @@ test("child and adjacent", function() {
|
||||||
|
|
||||||
t( "First Child", "p:first-child", ["firstp","sndp"] );
|
t( "First Child", "p:first-child", ["firstp","sndp"] );
|
||||||
t( "Nth Child", "p:nth-child(1)", ["firstp","sndp"] );
|
t( "Nth Child", "p:nth-child(1)", ["firstp","sndp"] );
|
||||||
|
|
||||||
|
// Verify that the child position isn't being cached improperly
|
||||||
|
jQuery("p:first-child").after("<div></div>");
|
||||||
|
jQuery("p:first-child").before("<div></div>").next().remove();
|
||||||
|
|
||||||
|
t( "First Child", "p:first-child", [] );
|
||||||
|
|
||||||
|
reset();
|
||||||
|
|
||||||
t( "Last Child", "p:last-child", ["sap"] );
|
t( "Last Child", "p:last-child", ["sap"] );
|
||||||
t( "Last Child", "a:last-child", ["simon1","anchor1","mark","yahoo","anchor2","simon"] );
|
t( "Last Child", "a:last-child", ["simon1","anchor1","mark","yahoo","anchor2","simon"] );
|
||||||
|
|
Loading…
Reference in a new issue