Mercurial > nebulaweb3
diff default/node_modules/shoestring/src/dom/prevAll.js @ 0:1d038bc9b3d2 default tip
Up:default
author | Liny <dev@neowd.com> |
---|---|
date | Sat, 31 May 2025 09:21:51 +0800 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/default/node_modules/shoestring/src/dom/prevAll.js Sat May 31 09:21:51 2025 +0800 @@ -0,0 +1,34 @@ +//>>excludeStart("exclude", pragmas.exclude); +define([ "shoestring", "dom/prev" ], function(){ +//>>excludeEnd("exclude"); + + /** + * Returns a `shoestring` object with the set of *all* siblings before each element in the original set. + * + * @return shoestring + * @this shoestring + */ + shoestring.fn.prevAll = function(){ + //>>includeStart("development", pragmas.development); + if( arguments.length > 0 ){ + shoestring.error( 'prevall-selector' ); + } + //>>includeEnd("development"); + + var result = []; + + this.each(function() { + var $previous = shoestring( this ).prev(); + + while( $previous.length ){ + result.push( $previous[0] ); + $previous = $previous.prev(); + } + }); + + return shoestring( result ); + }; + +//>>excludeStart("exclude", pragmas.exclude); +}); +//>>excludeEnd("exclude");