]>
git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/node_modules/space-pen/node_modules/jquery/src/traversing.js
d9ff0aeac4aa8b4e0907daed675ebf60278bc977
4 "./traversing/var/rneedsContext",
6 "./traversing/findFilter",
8 ], function( jQuery
, indexOf
, rneedsContext
) {
10 var rparentsprev
= /^(?:parents|prev(?:Until|All))/,
11 // Methods guaranteed to produce a unique set when starting from a unique set
20 dir: function( elem
, dir
, until
) {
22 truncate
= until
!== undefined;
24 while ( (elem
= elem
[ dir
]) && elem
.nodeType
!== 9 ) {
25 if ( elem
.nodeType
=== 1 ) {
26 if ( truncate
&& jQuery( elem
).is( until
) ) {
35 sibling: function( n
, elem
) {
38 for ( ; n
; n
= n
.nextSibling
) {
39 if ( n
.nodeType
=== 1 && n
!== elem
) {
49 has: function( target
) {
50 var targets
= jQuery( target
, this ),
53 return this.filter(function() {
55 for ( ; i
< l
; i
++ ) {
56 if ( jQuery
.contains( this, targets
[i
] ) ) {
63 closest: function( selectors
, context
) {
68 pos
= rneedsContext
.test( selectors
) || typeof selectors
!== "string" ?
69 jQuery( selectors
, context
|| this.context
) :
72 for ( ; i
< l
; i
++ ) {
73 for ( cur
= this[i
]; cur
&& cur
!== context
; cur
= cur
.parentNode
) {
74 // Always skip document fragments
75 if ( cur
.nodeType
< 11 && (pos
?
78 // Don't pass non-elements to Sizzle
80 jQuery
.find
.matchesSelector(cur
, selectors
)) ) {
88 return this.pushStack( matched
.length
> 1 ? jQuery
.unique( matched
) : matched
);
91 // Determine the position of an element within the set
92 index: function( elem
) {
94 // No argument, return index in parent
96 return ( this[ 0 ] && this[ 0 ].parentNode
) ? this.first().prevAll().length : -1;
100 if ( typeof elem
=== "string" ) {
101 return indexOf
.call( jQuery( elem
), this[ 0 ] );
104 // Locate the position of the desired element
105 return indexOf
.call( this,
107 // If it receives a jQuery object, the first element is used
108 elem
.jquery
? elem
[ 0 ] : elem
112 add: function( selector
, context
) {
113 return this.pushStack(
115 jQuery
.merge( this.get(), jQuery( selector
, context
) )
120 addBack: function( selector
) {
121 return this.add( selector
== null ?
122 this.prevObject : this.prevObject
.filter(selector
)
127 function sibling( cur
, dir
) {
128 while ( (cur
= cur
[dir
]) && cur
.nodeType
!== 1 ) {}
133 parent: function( elem
) {
134 var parent
= elem
.parentNode
;
135 return parent
&& parent
.nodeType
!== 11 ? parent : null;
137 parents: function( elem
) {
138 return jQuery
.dir( elem
, "parentNode" );
140 parentsUntil: function( elem
, i
, until
) {
141 return jQuery
.dir( elem
, "parentNode", until
);
143 next: function( elem
) {
144 return sibling( elem
, "nextSibling" );
146 prev: function( elem
) {
147 return sibling( elem
, "previousSibling" );
149 nextAll: function( elem
) {
150 return jQuery
.dir( elem
, "nextSibling" );
152 prevAll: function( elem
) {
153 return jQuery
.dir( elem
, "previousSibling" );
155 nextUntil: function( elem
, i
, until
) {
156 return jQuery
.dir( elem
, "nextSibling", until
);
158 prevUntil: function( elem
, i
, until
) {
159 return jQuery
.dir( elem
, "previousSibling", until
);
161 siblings: function( elem
) {
162 return jQuery
.sibling( ( elem
.parentNode
|| {} ).firstChild
, elem
);
164 children: function( elem
) {
165 return jQuery
.sibling( elem
.firstChild
);
167 contents: function( elem
) {
168 return elem
.contentDocument
|| jQuery
.merge( [], elem
.childNodes
);
170 }, function( name
, fn
) {
171 jQuery
.fn
[ name
] = function( until
, selector
) {
172 var matched
= jQuery
.map( this, fn
, until
);
174 if ( name
.slice( -5 ) !== "Until" ) {
178 if ( selector
&& typeof selector
=== "string" ) {
179 matched
= jQuery
.filter( selector
, matched
);
182 if ( this.length
> 1 ) {
184 if ( !guaranteedUnique
[ name
] ) {
185 jQuery
.unique( matched
);
188 // Reverse order for parents* and prev-derivatives
189 if ( rparentsprev
.test( name
) ) {
194 return this.pushStack( matched
);