Sha256: 255cac6df361daf223be25348245962fa81929a50e7c16fcdadb7279eed80ae9

Contents?: true

Size: 1.24 KB

Versions: 24

Compression:

Stored size: 1.24 KB

Contents

//>>excludeStart("exclude", pragmas.exclude);
define([ "shoestring" ], function(){
//>>excludeEnd("exclude");

	/**
	 * Returns a `shoestring` object with the set of *one* siblingx before each element in the original set.
	 *
	 * @return shoestring
	 * @this shoestring
	 */
	shoestring.fn.prev = function(){
		//>>includeStart("development", pragmas.development);
		if( arguments.length > 0 ){
			shoestring.error( 'prev-selector' );
		}
		//>>includeEnd("development");

		var result = [];

		// TODO need to implement map
		this.each(function() {
			var children, item, found;

			// get the child nodes for this member of the set
			children = shoestring( this.parentNode )[0].childNodes;

			for( var i = children.length -1; i >= 0; i-- ){
				item = children.item( i );

				// found the item we needed (found) which means current item value is
				// the next node in the list, as long as it's viable grab it
				// NOTE may need to be more permissive
				if( found && item.nodeType === 1 ){
					result.push( item );
					break;
				}

				// find the current item and mark it as found
				if( item === this ){
					found = true;
				}
			}
		});

		return shoestring( result );
	};

//>>excludeStart("exclude", pragmas.exclude);
});
//>>excludeEnd("exclude");

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
trusty-cms-6.3.1 node_modules/shoestring/src/dom/prev.js
trusty-cms-5.0.7 node_modules/shoestring/src/dom/prev.js
trusty-cms-5.0.6 node_modules/shoestring/src/dom/prev.js
trusty-cms-5.0.5 node_modules/shoestring/src/dom/prev.js
trusty-cms-5.0.4 node_modules/shoestring/src/dom/prev.js
trusty-cms-5.0.3 node_modules/shoestring/src/dom/prev.js
trusty-cms-5.0.2 node_modules/shoestring/src/dom/prev.js
trusty-cms-5.0.1 node_modules/shoestring/src/dom/prev.js
trusty-cms-4.3.5 node_modules/shoestring/src/dom/prev.js
trusty-cms-5.0.0 node_modules/shoestring/src/dom/prev.js
trusty-cms-4.3.4 node_modules/shoestring/src/dom/prev.js
trusty-cms-4.3.3 node_modules/shoestring/src/dom/prev.js
trusty-cms-4.3.2 node_modules/shoestring/src/dom/prev.js
trusty-cms-4.3.1 node_modules/shoestring/src/dom/prev.js
trusty-cms-4.3 node_modules/shoestring/src/dom/prev.js
trusty-cms-4.2.3 node_modules/shoestring/src/dom/prev.js
trusty-cms-4.2.2 node_modules/shoestring/src/dom/prev.js
trusty-cms-4.2.1 node_modules/shoestring/src/dom/prev.js
trusty-cms-4.2 node_modules/shoestring/src/dom/prev.js
trusty-cms-4.1.9 node_modules/shoestring/src/dom/prev.js