Skip to content

Instantly share code, notes, and snippets.

@zpao
Last active August 29, 2015 13:57
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 zpao/9677728 to your computer and use it in GitHub Desktop.
Save zpao/9677728 to your computer and use it in GitHub Desktop.
My code from https://news.ycombinator.com/item?id=7426312 but in a sane format
/* @jsx m.dom */
function m(type, props, children) {
// assuming m() looks something like this.
return {
type: type,
props: props,
children: children
};
}
m.render = function(lwDOM){
console.log(lwDOM)
};
m.dom = {};
// React hard codes this array so we can do something like this to build the mapping
['a', 'span'].forEach((el) => {
m.dom[el] = function(props, ...args) { return m.call(null, el, props, args); }
});
m.render(
<a href={"google.com"}>
<span>hello</span>
<span>world</span>
</a>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment