{"version":3,"file":"preact.js","sources":["../src/preact.js"],"sourcesContent":["// render modes\nconst NO_RENDER = { render: false };\nconst SYNC_RENDER = { renderSync: true };\nconst DOM_RENDER = { build: true };\n\nconst EMPTY = {};\nconst EMPTY_BASE = '';\n\n// is this a DOM environment\nconst HAS_DOM = typeof document!=='undefined';\nconst TEXT_CONTENT = !HAS_DOM || 'textContent' in document ? 'textContent' : 'nodeValue';\n\nconst ATTR_PREFIX = '__preactattr_';\n\n// DOM properties that should NOT have \"px\" added when numeric\nconst NON_DIMENSION_PROPS = {\n\tboxFlex:1,boxFlexGroup:1,columnCount:1,fillOpacity:1,flex:1,flexGrow:1,\n\tflexPositive:1,flexShrink:1,flexNegative:1,fontWeight:1,lineClamp:1,lineHeight:1,\n\topacity:1,order:1,orphans:1,strokeOpacity:1,widows:1,zIndex:1,zoom:1\n};\n\n// convert an Array-like object to an Array\nlet toArray = obj => {\n\tlet arr = [];\n\tfor (let i=obj.length; i--; ) arr[i] = obj[i];\n\treturn arr;\n};\n\nlet hop = Object.prototype.hasOwnProperty;\n\n/** Create a caching wrapper for the given function.\n *\t@private\n */\nlet memoize = (fn, mem={}) => k => hop.call(mem, k) ? mem[k] : (mem[k] = fn(k));\n\n/** Get a deep property value from the given object, expressed in dot-notation.\n *\t@private\n */\nlet delve = (obj, key) => (key.split('.').map( p => (obj = obj && obj[p]) ), obj);\n\n\n\n/** Global options\n *\t@public\n *\t@namespace {Object}\n */\nlet options = {\n\t/** If `true`, `prop` changes trigger synchronous component updates.\n\t *\t@boolean\n\t */\n\tsyncComponentUpdates: true,\n\n\t/** Processes all created VNodes.\n\t *\t@param {VNode} vnode\tA newly-created VNode to normalize/process\n\t *\t@protected\n\t */\n\tvnode(n) {\n\t\tlet attrs = n.attributes;\n\t\tif (!attrs) return;\n\n\t\tlet s = attrs.style;\n\t\tif (s && !s.substring) {\n\t\t\tattrs.style = styleObjToCss(s);\n\t\t}\n\n\t\tlet c = attrs['class'];\n\t\tif (hop.call(attrs, 'className')) {\n\t\t\tc = attrs['class'] = attrs.className;\n\t\t\tdelete attrs.className;\n\t\t}\n\t\tif (c && !c.substring) {\n\t\t\tattrs['class'] = hashToClassName(c);\n\t\t}\n\t}\n};\n\n\n\n/** Base Component class, for he ES6 Class method of creating Components\n *\t@public\n *\n *\t@example\n *\tclass MyFoo extends Component {\n *\t\trender(props, state) {\n *\t\t\treturn
;\n *\t\t}\n *\t}\n */\nclass Component {\n\tconstructor(props, context) {\n\t\t/** @private */\n\t\tthis._dirty = this._disableRendering = false;\n\t\t/** @private */\n\t\tthis._linkedStates = {};\n\t\t/** @private */\n\t\tthis._renderCallbacks = [];\n\t\t/** @public */\n\t\tthis.prevState = this.prevProps = this.prevContext = this.base = null;\n\t\t/** @public */\n\t\tthis.context = context || null;\n\t\t/** @type {object} */\n\t\tthis.props = props || hook(this, 'getDefaultProps') || {};\n\t\t/** @type {object} */\n\t\tthis.state = hook(this, 'getInitialState') || {};\n\t}\n\n\t/** Returns a `boolean` value indicating if the component should re-render when receiving the given `props` and `state`.\n\t *\t@param {object} nextProps\n\t *\t@param {object} nextState\n\t *\t@param {object} nextContext\n\t *\t@returns {Boolean} should the component re-render\n\t *\t@name shouldComponentUpdate\n\t *\t@function\n\t */\n\t// shouldComponentUpdate() {\n\t// \treturn true;\n\t// }\n\n\t/** Returns a function that sets a state property when called.\n\t *\tCalling linkState() repeatedly with the same arguments returns a cached link function.\n\t *\n\t *\tProvides some built-in special cases:\n\t *\t\t- Checkboxes and radio buttons link their boolean `checked` value\n\t *\t\t- Inputs automatically link their `value` property\n\t *\t\t- Event paths fall back to any associated Component if not found on an element\n\t *\t\t- If linked value is a function, will invoke it and use the result\n\t *\n\t *\t@param {string} key\t\t\t\tThe path to set - can be a dot-notated deep key\n\t *\t@param {string} [eventPath]\t\tIf set, attempts to find the new state value at a given dot-notated path within the object passed to the linkedState setter.\n\t *\t@returns {function} linkStateSetter(e)\n\t *\n\t *\t@example Update a \"text\" state value when an input changes:\n\t *\t\t\n\t *\n\t *\t@example Set a deep state value on click\n\t *\t\t|undefined} */\n\t\tthis.attributes = attributes;\n\n\t\t/** @type {array