Created
June 23, 2022 23:52
-
-
Save Nick-Gabe/269a4f70b6b7c8f8bb27eda3e7c3aa48 to your computer and use it in GitHub Desktop.
Adds styles to a Html Element based on a CSS Object.
This file contains 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
interface HTMLElement { | |
setStyle(newStyles: Partial<CSSStyleDeclaration>): void; | |
} | |
HTMLElement.prototype.setStyle = function (newStyles) { | |
for (let style in newStyles) { | |
this.style[style] = newStyles[style]! | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment