diff --git a/clamp.js b/clamp.js index f13e8ad..274f271 100644 --- a/clamp.js +++ b/clamp.js @@ -49,10 +49,13 @@ * @returns {number} */ function computeStyle(elem, prop) { - if (!win.getComputedStyle) { - win.getComputedStyle = function(el, pseudo) { + var getComputedStyle; + if (win.getComputedStyle) { + getComputedStyle = win.getComputedStyle; + } else { + getComputedStyle = function (el, pseudo) { this.el = el; - this.getPropertyValue = function(prop) { + this.getPropertyValue = function (prop) { var re = /(\-([a-z]){1})/g; if (prop == 'float') prop = 'styleFloat'; if (re.test(prop)) { @@ -66,7 +69,7 @@ } } - return win.getComputedStyle(elem, null).getPropertyValue(prop); + return getComputedStyle(elem, null).getPropertyValue(prop); } /**