Mercurial > nebulaweb3
comparison default/node_modules/shoestring/src/dom/next.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 a `shoestring` object with the set of siblings of each element in the original set. | |
7 * | |
8 * @return shoestring | |
9 * @this shoestring | |
10 */ | |
11 shoestring.fn.next = function(){ | |
12 //>>includeStart("development", pragmas.development); | |
13 if( arguments.length > 0 ){ | |
14 shoestring.error( 'next-selector' ); | |
15 } | |
16 //>>includeEnd("development"); | |
17 | |
18 var result = []; | |
19 | |
20 // TODO need to implement map | |
21 this.each(function() { | |
22 var children, item, found; | |
23 | |
24 // get the child nodes for this member of the set | |
25 children = shoestring( this.parentNode )[0].childNodes; | |
26 | |
27 for( var i = 0; i < children.length; i++ ){ | |
28 item = children.item( i ); | |
29 | |
30 // found the item we needed (found) which means current item value is | |
31 // the next node in the list, as long as it's viable grab it | |
32 // NOTE may need to be more permissive | |
33 if( found && item.nodeType === 1 ){ | |
34 result.push( item ); | |
35 break; | |
36 } | |
37 | |
38 // find the current item and mark it as found | |
39 if( item === this ){ | |
40 found = true; | |
41 } | |
42 } | |
43 }); | |
44 | |
45 return shoestring( result ); | |
46 }; | |
47 | |
48 //>>excludeStart("exclude", pragmas.exclude); | |
49 }); | |
50 //>>excludeEnd("exclude"); |