Mercurial > nebulaweb3
comparison default/node_modules/shoestring/src/dom/parents.js @ 0:1d038bc9b3d2 default tip
Up:default
author | Liny <dev@neowd.com> |
---|---|
date | Sat, 31 May 2025 09:21:51 +0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1d038bc9b3d2 |
---|---|
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"); |