Skip to content

Instantly share code, notes, and snippets.

@developit
Created May 30, 2019 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save developit/d55dc3c47dd1fe81d84f5ee0ab5bfc58 to your computer and use it in GitHub Desktop.
Save developit/d55dc3c47dd1fe81d84f5ee0ab5bfc58 to your computer and use it in GitHub Desktop.
Support for string styles in Preact X: <div style="color: red;">
{
"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"
}
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