Created
May 30, 2019 15:19
-
-
Save developit/d55dc3c47dd1fe81d84f5ee0ab5bfc58 to your computer and use it in GitHub Desktop.
Support for string styles in Preact X: <div style="color: red;">
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
{ | |
"name": "preact-string-styles", | |
"main": "preact-string-styles.js", | |
"module": "preact-string-styles.js", | |
"version": "0.1.0", | |
"homepage": "https://gist.github.com/developit/d55dc3c47dd1fe81d84f5ee0ab5bfc58" | |
} |
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
import { options } from 'preact'; | |
const old = options.vnode; | |
options.vnode = vnode => { | |
if (vnode.props && typeof vnode.props.style==='string') { | |
vnode.props.style = { | |
cssText: vnode.props.style | |
}; | |
} | |
if (old) old(vnode); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment