diff default/node_modules/shoestring/src/dom/css.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/css.js	Sat May 31 09:21:51 2025 +0800
@@ -0,0 +1,46 @@
+//>>excludeStart("exclude", pragmas.exclude);
+define([
+  "shoestring",
+  "dom/css/getStyle",
+  "dom/css/setStyle"
+], function(){
+//>>excludeEnd("exclude");// TODO: This code should be consistent with attr().
+
+	/**
+	 * Get the compute style property of the first element or set the value of a style property
+	 * on all elements in the set.
+	 *
+	 * @method _setStyle
+	 * @param {string} property The property being used to style the element.
+	 * @param {string|undefined} value The css value for the style property.
+	 * @return {string|shoestring}
+	 * @this shoestring
+	 */
+	shoestring.fn.css = function( property, value ){
+		if( !this[0] ){
+			return;
+		}
+
+		if( typeof property === "object" ) {
+			return this.each(function() {
+				for( var key in property ) {
+					if( property.hasOwnProperty( key ) ) {
+						shoestring._setStyle( this, key, property[key] );
+					}
+				}
+			});
+		}	else {
+			// assignment else retrieve first
+			if( value !== undefined ){
+				return this.each(function(){
+					shoestring._setStyle( this, property, value );
+				});
+			}
+
+			return shoestring._getStyle( this[0], property );
+		}
+	};
+
+//>>excludeStart("exclude", pragmas.exclude);
+});
+//>>excludeEnd("exclude");