mirror of
https://github.com/jquery/jquery.git
synced 2026-02-11 22:35:08 -05:00
Traversing: Don't expose jQuery.dir & jQuery.sibling
jQuery.dir & jQuery.sibling are undocumented internal APIs; they shouldn't
be exposed.
(cherry-picked from f9ef427d35)
Fixes gh-2512
Closes gh-2525
This commit is contained in:
20
src/traversing/var/dir.js
Normal file
20
src/traversing/var/dir.js
Normal file
@@ -0,0 +1,20 @@
|
||||
define( [
|
||||
"../../core"
|
||||
], function( jQuery ) {
|
||||
|
||||
return function( elem, dir, until ) {
|
||||
var matched = [],
|
||||
truncate = until !== undefined;
|
||||
|
||||
while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
|
||||
if ( elem.nodeType === 1 ) {
|
||||
if ( truncate && jQuery( elem ).is( until ) ) {
|
||||
break;
|
||||
}
|
||||
matched.push( elem );
|
||||
}
|
||||
}
|
||||
return matched;
|
||||
};
|
||||
|
||||
} );
|
||||
15
src/traversing/var/siblings.js
Normal file
15
src/traversing/var/siblings.js
Normal file
@@ -0,0 +1,15 @@
|
||||
define( function() {
|
||||
|
||||
return function( n, elem ) {
|
||||
var matched = [];
|
||||
|
||||
for ( ; n; n = n.nextSibling ) {
|
||||
if ( n.nodeType === 1 && n !== elem ) {
|
||||
matched.push( n );
|
||||
}
|
||||
}
|
||||
|
||||
return matched;
|
||||
};
|
||||
|
||||
} );
|
||||
Reference in New Issue
Block a user