Skip to content

Commit

Permalink
[dom] Optimize dom-style.js
Browse files Browse the repository at this point in the history
* Remove unnecessary anonymous function, unused variables.
* Use "Number()" instead of "new Number()".
  • Loading branch information
okuryu committed Mar 6, 2014
1 parent 27d5900 commit 889e9bb
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/dom/js/dom-style.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
(function(Y) {
/**
* Add style management functionality to DOM.
* @module dom
Expand All @@ -17,9 +16,7 @@ var DOCUMENT_ELEMENT = 'documentElement',
GET_COMPUTED_STYLE = 'getComputedStyle',
GET_BOUNDING_CLIENT_RECT = 'getBoundingClientRect',

WINDOW = Y.config.win,
DOCUMENT = Y.config.doc,
UNDEFINED = undefined,

Y_DOM = Y.DOM,

Expand Down Expand Up @@ -64,7 +61,7 @@ Y.mix(Y_DOM, {
if (style) {
if (val === null || val === '') { // normalize unsetting
val = '';
} else if (!isNaN(new Number(val)) && re_unit.test(att)) { // number values may need a unit
} else if (!isNaN(Number(val)) && re_unit.test(att)) { // number values may need a unit
val += Y_DOM.DEFAULT_UNIT;
}

Expand Down Expand Up @@ -148,9 +145,9 @@ Y.mix(Y_DOM, {
});

// normalize reserved word float alternatives ("cssFloat" or "styleFloat")
if (DOCUMENT[DOCUMENT_ELEMENT][STYLE][CSS_FLOAT] !== UNDEFINED) {
if (DOCUMENT[DOCUMENT_ELEMENT][STYLE][CSS_FLOAT] !== undefined) {
Y_DOM.CUSTOM_STYLES[FLOAT] = CSS_FLOAT;
} else if (DOCUMENT[DOCUMENT_ELEMENT][STYLE][STYLE_FLOAT] !== UNDEFINED) {
} else if (DOCUMENT[DOCUMENT_ELEMENT][STYLE][STYLE_FLOAT] !== undefined) {
Y_DOM.CUSTOM_STYLES[FLOAT] = STYLE_FLOAT;
}

Expand Down Expand Up @@ -244,7 +241,7 @@ Y_DOM.CUSTOM_STYLES.transform = {
style[TRANSFORM] = val;
},

get: function(node, style) {
get: function(node) {
return Y_DOM[GET_COMPUTED_STYLE](node, TRANSFORM);
}
};
Expand All @@ -254,10 +251,7 @@ Y_DOM.CUSTOM_STYLES.transformOrigin = {
style[TRANSFORMORIGIN] = val;
},

get: function(node, style) {
get: function(node) {
return Y_DOM[GET_COMPUTED_STYLE](node, TRANSFORMORIGIN);
}
};


})(Y);

0 comments on commit 889e9bb

Please sign in to comment.