Last active
August 29, 2015 13:57
-
-
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
This file contains hidden or 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
/* @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