Commit 0f03c748 authored by rkatic's avatar rkatic Committed by John Resig

Store last closer value to jQuery.lastCloser instead of using data API.

parent 3106039a
...@@ -52,19 +52,20 @@ jQuery.fn.extend({ ...@@ -52,19 +52,20 @@ jQuery.fn.extend({
}, },
closest: function( selector, context ) { closest: function( selector, context ) {
var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null;
closer = 0;
return this.map(function(){ return this.map(function(){
var cur = this; var cur = this, closer = 0;
while ( cur && cur.ownerDocument && cur !== context ) { while ( cur && cur.ownerDocument && cur !== context ) {
if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) {
jQuery.data(cur, "closest", closer); jQuery.lastCloser = closer;
return cur; return cur;
} }
cur = cur.parentNode; cur = cur.parentNode;
closer++; closer++;
} }
jQuery.lastCloser = -1;
return null;
}); });
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment