comparison default/node_modules/shoestring/src/dom/css/setStyle.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([
3 "shoestring",
4 "dom/css/exceptions"
5 ], function(){
6 //>>excludeEnd("exclude");// TODO: This code should be consistent with attr().
7
8 (function() {
9 var cssExceptions = shoestring.cssExceptions;
10
11 // marginRight instead of margin-right
12 function convertPropertyName( str ) {
13 return str.replace( /\-([A-Za-z])/g, function ( match, character ) {
14 return character.toUpperCase();
15 });
16 }
17
18 /**
19 * Private function for setting the style of an element.
20 *
21 * **NOTE** Please use the [css](../css.js.html) method instead.
22 *
23 * @method _setStyle
24 * @param {HTMLElement} element The element we want to style.
25 * @param {string} property The property being used to style the element.
26 * @param {string} value The css value for the style property.
27 */
28 shoestring._setStyle = function( element, property, value ) {
29 var convertedProperty = convertPropertyName(property);
30
31 element.style[ property ] = value;
32
33 if( convertedProperty !== property ) {
34 element.style[ convertedProperty ] = value;
35 }
36
37 if( cssExceptions[ property ] ) {
38 for( var j = 0, k = cssExceptions[ property ].length; j<k; j++ ) {
39 element.style[ cssExceptions[ property ][ j ] ] = value;
40 }
41 }
42 };
43 })();
44
45 //>>excludeStart("exclude", pragmas.exclude);
46 });
47 //>>excludeEnd("exclude");