0
|
1 //>>excludeStart("exclude", pragmas.exclude);
|
|
2 define([ "shoestring" ], function(){
|
|
3 //>>excludeEnd("exclude");
|
|
4
|
|
5 /**
|
|
6 * Returns the set of all parents matching the selector if provided for each element in the current set.
|
|
7 *
|
|
8 * @param {string} selector The selector to check the parents with.
|
|
9 * @return shoestring
|
|
10 * @this shoestring
|
|
11 */
|
|
12 shoestring.fn.parents = function( selector ){
|
|
13 var ret = [];
|
|
14
|
|
15 this.each(function(){
|
|
16 var curr = this, match;
|
|
17
|
|
18 while( curr.parentElement && !match ){
|
|
19 curr = curr.parentElement;
|
|
20
|
|
21 if( selector ){
|
|
22 if( curr === shoestring( selector )[0] ){
|
|
23 match = true;
|
|
24
|
|
25 if( shoestring.inArray( curr, ret ) === -1 ){
|
|
26 ret.push( curr );
|
|
27 }
|
|
28 }
|
|
29 } else {
|
|
30 if( shoestring.inArray( curr, ret ) === -1 ){
|
|
31 ret.push( curr );
|
|
32 }
|
|
33 }
|
|
34 }
|
|
35 });
|
|
36
|
|
37 return shoestring(ret);
|
|
38 };
|
|
39
|
|
40 //>>excludeStart("exclude", pragmas.exclude);
|
|
41 });
|
|
42 //>>excludeEnd("exclude");
|