{"version":3,"file":null,"sources":["../src/index.js"],"sourcesContent":["import PropTypes from 'proptypes';\nimport { render as preactRender, cloneElement as preactCloneElement, h, Component as PreactComponent, options } from 'preact';\n\nconst version = '15.1.0'; // trick libraries to think we are react\n\nconst ELEMENTS = 'a abbr address area article aside audio b base bdi bdo big blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins kbd keygen label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script section select small source span strong style sub summary sup table tbody td textarea tfoot th thead time title tr track u ul var video wbr circle clipPath defs ellipse g image line linearGradient mask path pattern polygon polyline radialGradient rect stop svg text tspan'.split(' ');\n\nconst REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) || 0xeac7;\n\n// don't autobind these methods since they already have guaranteed context.\nconst AUTOBIND_BLACKLIST = {\n\tconstructor: 1,\n\trender: 1,\n\tshouldComponentUpdate: 1,\n\tcomponentWillRecieveProps: 1,\n\tcomponentWillUpdate: 1,\n\tcomponentDidUpdate: 1,\n\tcomponentWillMount: 1,\n\tcomponentDidMount: 1,\n\tcomponentWillUnmount: 1,\n\tcomponentDidUnmount: 1\n};\n\n\nconst BYPASS_HOOK = {};\n\n/*global process*/\nconst DEV = typeof process!=='undefined' && process.env && process.env.NODE_ENV!=='production';\n\n// a component that renders nothing. Used to replace components for unmountComponentAtNode.\nconst EmptyComponent = () => null;\n\n\n\n// make react think we're react.\nlet VNode = h('').constructor;\nVNode.prototype.$$typeof = REACT_ELEMENT_TYPE;\n\nObject.defineProperty(VNode.prototype, 'type', {\n\tget() { return this.nodeName; },\n\tset(v) { this.nodeName = v; }\n});\n\nObject.defineProperty(VNode.prototype, 'props', {\n\tget() { return this.attributes; },\n\tset(v) { this.attributes = v; }\n});\n\n\nlet oldVnodeHook = options.vnode || EmptyComponent;\noptions.vnode = vnode => {\n\tlet a = vnode.attributes;\n\tif (!a) a = vnode.attributes = {};\n\t// clone if needed (fixes #105):\n\tif (Object.isExtensible && !Object.isExtensible(a)) {\n\t\ta = extend({}, a, true);\n\t}\n\ta.children = vnode.children;\n\toldVnodeHook(vnode);\n};\n\n\n\n// proxy render() since React returns a Component reference.\nfunction render(vnode, parent, callback) {\n\tlet prev = parent._preactCompatRendered;\n\tif (prev && prev.parentNode!==parent) prev = null;\n\tlet out = preactRender(vnode, parent, prev);\n\tparent._preactCompatRendered = out;\n\tif (typeof callback==='function') callback();\n\treturn out && out._component;\n}\n\n\nfunction unmountComponentAtNode(container) {\n\tlet existing = container._preactCompatRendered;\n\tif (existing && existing.parentNode===container) {\n\t\tpreactRender(h(EmptyComponent), container, existing);\n\t\treturn true;\n\t}\n\treturn false;\n}\n\n\n\nconst ARR = [];\n\n// This API is completely unnecessary for Preact, so it's basically passthrough.\nlet Children = {\n\tmap(children, fn, ctx) {\n\t\tchildren = Children.toArray(children);\n\t\tif (ctx && ctx!==children) fn = fn.bind(ctx);\n\t\treturn children.map(fn);\n\t},\n\tforEach(children, fn, ctx) {\n\t\tchildren = Children.toArray(children);\n\t\tif (ctx && ctx!==children) fn = fn.bind(ctx);\n\t\tchildren.forEach(fn);\n\t},\n\tcount(children) {\n\t\tchildren = Children.toArray(children);\n\t\treturn children.length;\n\t},\n\tonly(children) {\n\t\tchildren = Children.toArray(children);\n\t\tif (children.length!==1) throw new Error('Children.only() expects only one child.');\n\t\treturn children[0];\n\t},\n\ttoArray(children) {\n\t\treturn Array.isArray && Array.isArray(children) ? children : ARR.concat(children);\n\t}\n};\n\n\n/** Track current render() component for ref assignment */\nlet currentComponent;\n\n\nfunction createFactory(type) {\n\treturn createElement.bind(null, type);\n}\n\n\nlet DOM = {};\nfor (let i=ELEMENTS.length; i--; ) {\n\tDOM[ELEMENTS[i]] = createFactory(ELEMENTS[i]);\n}\n\n\nfunction createElement(...args) {\n\tlet vnode = h(...args);\n\n\tapplyClassName(vnode);\n\n\tlet ref = vnode.attributes && vnode.attributes.ref,\n\t\ttype = ref && typeof ref;\n\tif (currentComponent && (type==='string' || type==='number')) {\n\t\tvnode.attributes.ref = createStringRefProxy(ref, currentComponent);\n\t}\n\n\treturn vnode;\n}\n\n\nfunction cloneElement(element, props, ...children) {\n\tlet node = h(\n\t\telement.nodeName || element.type,\n\t\telement.attributes || element.props,\n\t\telement.children || element.props.children\n\t);\n\tif (preactCloneElement) {\n\t\treturn preactCloneElement(node, props, ...children);\n\t}\n\treturn createElement(\n\t\tnode.nodeName,\n\t\textend(extend({}, node.attributes || {}), props),\n\t\t...(children.length && children || node.children || [])\n\t);\n}\n\n\nfunction isValidElement(element) {\n\treturn element && ((element instanceof VNode) || element.$$typeof===REACT_ELEMENT_TYPE);\n}\n\n\nfunction createStringRefProxy(name, component) {\n\treturn component._refProxies[name] || (component._refProxies[name] = resolved => {\n\t\tif (component && component.refs) {\n\t\t\tcomponent.refs[name] = resolved;\n\t\t\tif (resolved===null) {\n\t\t\t\tdelete component._refProxies[name];\n\t\t\t\tcomponent = null;\n\t\t\t}\n\t\t}\n\t});\n}\n\n\nfunction applyClassName({ attributes }) {\n\tif (!attributes) return;\n\tlet cl = attributes.className || attributes.class;\n\tif (cl) attributes.className = cl;\n}\n\n\nfunction extend(base, props, all) {\n\tfor (let key in props) {\n\t\tif (all===true || props[key]!=null) {\n\t\t\tbase[key] = props[key];\n\t\t}\n\t}\n\treturn base;\n}\n\n\nlet findDOMNode = component => component.base || component;\n\n\nfunction F(){}\n\nfunction createClass(obj) {\n\tfunction cl(props, context) {\n\t\textend(this, obj);\n\t\tComponent.call(this, props, context, BYPASS_HOOK);\n\t\tbindAll(this);\n\t\tnewComponentHook.call(this, props, context);\n\t}\n\n\tif (obj.statics) {\n\t\textend(cl, obj.statics);\n\t}\n\tif (obj.propTypes) {\n\t\tcl.propTypes = obj.propTypes;\n\t}\n\tif (obj.defaultProps) {\n\t\tcl.defaultProps = obj.defaultProps;\n\t}\n\tif (obj.getDefaultProps) {\n\t\tcl.defaultProps = obj.getDefaultProps();\n\t}\n\n\tF.prototype = Component.prototype;\n\tcl.prototype = new F();\n\tcl.prototype.constructor = cl;\n\n\tcl.displayName = obj.displayName || 'Component';\n\n\treturn cl;\n}\n\n\nfunction bindAll(ctx) {\n\tfor (let i in ctx) {\n\t\tlet v = ctx[i];\n\t\tif (typeof v==='function' && !v.__bound && !AUTOBIND_BLACKLIST.hasOwnProperty(i)) {\n\t\t\t(ctx[i] = v.bind(ctx)).__bound = true;\n\t\t}\n\t}\n}\n\n\nfunction callMethod(ctx, m, args) {\n\tif (typeof m==='string') {\n\t\tm = ctx.constructor.prototype[m];\n\t}\n\tif (typeof m==='function') {\n\t\treturn m.apply(ctx, args);\n\t}\n}\n\nfunction multihook() {\n\tlet hooks = arguments;\n\treturn function() {\n\t\tlet ret;\n\t\tfor (let i=0; i