Skip to content

Instantly share code, notes, and snippets.

@developit
Created September 2, 2019 20:48
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/19f94858690dd65c533bb6b885b85800 to your computer and use it in GitHub Desktop.
Save developit/19f94858690dd65c533bb6b885b85800 to your computer and use it in GitHub Desktop.

Temporarily bring back legacy VNode properties

Usage: just import the code from somewhere.

import './upgrade-polyfill';
import { options } from 'preact';
const EMPTY = [];
let old = options.vnode;
options.vnode = vnode => {
vnode.attributes = vnode.props;
vnode.nodeName = vnode.type;
vnode.children = vnode.props && vnode.props.children || EMPTY;
if (old) old(vnode);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment