Overwrite an element's style using cssText

This is the proper way to do it:
https://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-cssText
This commit is contained in:
Gilbert 2016-08-05 00:49:26 -05:00
parent 4f8dc68426
commit b0848070bc

View file

@ -441,11 +441,11 @@ module.exports = function($window) {
//style
function updateStyle(element, old, style) {
if (old === style) element.style = "", old = null
if (style == null) element.style = ""
else if (typeof style === "string") element.style = style
if (old === style) element.cssText = "", old = null
if (style == null) element.cssText = ""
else if (typeof style === "string") element.cssText = style
else {
if (typeof old === "string") element.style = ""
if (typeof old === "string") element.cssText = ""
for (var key in style) {
element.style[key] = style[key]
}