Created
December 1, 2017 20:39
-
-
Save FuruholmAnton/5ebf084b33a1be3796afed56fe9125f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Set CSS values on element | |
* | |
* @param {any} el | |
* @param {Object} styles | |
*/ | |
function css(el, styles) { | |
if (!el) return; | |
if (Array.isArray(el) || el instanceof NodeList) { | |
el.forEach((n) => { | |
css(n, styles); | |
}); | |
} else { | |
for (let [key, value] of entries(styles)) { | |
el.style[key] = value; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment