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
| function shouldBeProp (item) { | |
| return typeof item === 'function' || typeof item === 'object'; | |
| } | |
| window.React = { | |
| createElement (name, attrs, ...chren) { | |
| const node = typeof name === 'function' ? name() : document.createElement(name); | |
| Object.keys(attrs || []).forEach(attr => shouldBeProp(attrs[attr]) ? node[attr] = attrs[attr] : node.setAttribute(attr, attrs[attr])); | |
| chren.forEach(child => node.appendChild(child instanceof Node ? child : document.createTextNode(child))); | |
| return node; |