diff --git a/dist/react-lite.common.js b/dist/react-lite.common.js index f8209e4..5a867cb 100644 --- a/dist/react-lite.common.js +++ b/dist/react-lite.common.js @@ -1,5 +1,5 @@ /*! - * react-lite.js v0.0.28 + * react-lite.js v0.0.29 * (c) 2016 Jade Gu * Released under the MIT License. */ @@ -312,81 +312,6 @@ var notBubbleEvents = { oncontextmenu: TRUE }; -var isValidElement = function isValidElement(obj) { - return obj != null && !!obj.vtype; -}; - -var cloneElement = function cloneElement(originElem, props) { - for (var _len = arguments.length, children = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - children[_key - 2] = arguments[_key]; - } - - var type = originElem.type; - var key = originElem.key; - var ref = originElem.ref; - - var newProps = extend(extend({ key: key, ref: ref }, originElem.props), props); - var vnode = createElement.apply(undefined, [type, newProps].concat(children)); - if (vnode.ref === originElem.ref) { - vnode.refs = originElem.refs; - } - return vnode; -}; - -var createFactory = function createFactory(type) { - var factory = function factory() { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return createElement.apply(undefined, [type].concat(args)); - }; - factory.type = type; - return factory; -}; - -var createElement = function createElement(type, props) { - for (var _len3 = arguments.length, children = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { - children[_key3 - 2] = arguments[_key3]; - } - - var createVnode = undefined; - switch (true) { - case isStr(type): - createVnode = createVelem; - break; - case isComponent(type): - createVnode = createVcomponent; - break; - case isStatelessComponent(type): - createVnode = createVstatelessComponent; - break; - default: - throw new Error('React.createElement: unexpect type [ ' + type + ' ]'); - } - var key = null; - var ref = null; - var hasRef = false; - if (props != null) { - if (props.key !== undefined) { - key = '' + props.key; - delete props.key; - } - if (props.ref !== undefined) { - ref = props.ref; - delete props.ref; - hasRef = true; - } - } - var vnode = createVnode(type, mergeProps(props, children, type.defaultProps)); - vnode.key = key; - vnode.ref = ref; - if (hasRef && createVnode !== createVstatelessComponent) { - handleVnodeWithRef(vnode); - } - return vnode; -}; - var diff = function diff(vnode, newVnode) { var type = undefined; switch (true) { @@ -440,7 +365,7 @@ var isStatelessComponent = function isStatelessComponent(obj) { var hasOwn = function hasOwn(obj, key) { return Object.prototype.hasOwnProperty.call(obj, key); }; -var noop$1 = function noop() {}; +var noop = function noop() {}; var identity = function identity(obj) { return obj; }; @@ -746,7 +671,8 @@ if (!Object.freeze) { Object.freeze = identity; } -var noop$2 = noop$1; +var noop$1 = noop; +var refs = null; var initTree = function initTree(vtree, parentNode, parentContext) { var vtype = vtree.vtype; @@ -826,7 +752,8 @@ var createVelem = function createVelem(type, props) { return { vtype: VNODE_TYPE.ELEMENT, type: type, - props: props + props: props, + refs: refs }; }; @@ -905,7 +832,7 @@ var destroyVelem = function destroyVelem(velem, node) { if (children) { var childNodes = node.childNodes; var $removeNode = removeNode; - removeNode = noop$2; + removeNode = noop$1; var len = children.length; var i = -1; while (len--) { @@ -980,7 +907,8 @@ var createVcomponent = function createVcomponent(type, props) { id: getUid(), vtype: VNODE_TYPE.COMPONENT, type: type, - props: props + props: props, + refs: refs }; }; @@ -997,8 +925,10 @@ var initVcomponent = function initVcomponent(vcomponent, parentNode, parentConte cache.parentContext = parentContext; updater.isPending = true; component.props = component.props || props; - component.componentWillMount(); - component.state = updater.getState(); + if (component.componentWillMount) { + component.componentWillMount(); + component.state = updater.getState(); + } var vtree = renderComponent(component, parentContext); var node = initTree(vtree, parentNode, vtree.context); node.cache = node.cache || {}; @@ -1023,9 +953,11 @@ var updateVcomponent = function updateVcomponent(vcomponent, newVcomponent, node delete node.cache[id]; node.cache[newVcomponent.id] = component; cache.parentContext = parentContext; - updater.isPending = true; - component.componentWillReceiveProps(nextProps, componentContext); - updater.isPending = false; + if (component.componentWillReceiveProps) { + updater.isPending = true; + component.componentWillReceiveProps(nextProps, componentContext); + updater.isPending = false; + } updater.emitUpdate(nextProps, componentContext); updateRef(vcomponent, newVcomponent, component); return cache.node; @@ -1037,20 +969,16 @@ var destroyVcomponent = function destroyVcomponent(vcomponent, node) { var cache = component.$cache; delete node.cache[id]; detachRef(vcomponent); - component.setState = component.forceUpdate = noop$2; - component.componentWillUnmount(); + component.setState = component.forceUpdate = noop$1; + if (component.componentWillUnmount) { + component.componentWillUnmount(); + } destroyTree(cache.vtree, node); delete component.setState; cache.isMounted = false; cache.node = cache.parentContext = cache.vtree = component.refs = component.context = null; }; -var setRefs = noop$2; -var handleVnodeWithRef = function handleVnodeWithRef(vnode) { - if (setRefs !== noop$2) { - setRefs(vnode); - } -}; var getContextByTypes = function getContextByTypes(curContext, contextTypes) { var context = {}; if (!contextTypes || !curContext) { @@ -1064,27 +992,23 @@ var getContextByTypes = function getContextByTypes(curContext, contextTypes) { return context; }; -var bindRefs = function bindRefs(refs) { - return function (vnode) { - vnode.refs = vnode.refs || refs; - }; -}; - var renderComponent = function renderComponent(component, parentContext) { - setRefs = bindRefs(component.refs); + refs = component.refs; var vtree = component.render(); if (isUndefined(vtree)) { throw new Error('component can not render undefined'); } vtree = getVnode(vtree); - var curContext = component.getChildContext(); + var curContext = refs = null; + if (component.getChildContext) { + curContext = component.getChildContext(); + } if (curContext) { curContext = extend(extend({}, parentContext), curContext); } else { curContext = parentContext; } vtree.context = curContext; - setRefs = noop$2; return vtree; }; @@ -1100,7 +1024,9 @@ var clearPendingComponents = function clearPendingComponents() { while (len--) { var component = components[++i]; var updater = component.$updater; - component.componentDidMount(); + if (component.componentDidMount) { + component.componentDidMount(); + } updater.isPending = false; updater.emitUpdate(); } @@ -1117,7 +1043,7 @@ function compareTwoTrees(vtree, newVtree, node, parentNode, parentContext) { break; case DIFF_TYPE.REPLACE: var $removeNode = removeNode; - removeNode = noop$2; + removeNode = noop$1; destroyTree(vtree, node); removeNode = $removeNode; newNode = initTree(newVtree, function (nextNode) { @@ -1149,7 +1075,7 @@ var appendNode = function appendNode(parentNode, node) { var getVnode = function getVnode(vnode) { if (vnode === null) { vnode = createVelem('noscript', {}); - } else if (!vnode.vtype) { + } else if (!vnode || !vnode.vtype) { vnode = createVtext(vnode); } return vnode; @@ -1338,19 +1264,18 @@ function Component(props, context) { this.context = context || {}; } -var noop = noop$1; Component.prototype = { constructor: Component, - getChildContext: noop, - componentWillUpdate: noop, - componentDidUpdate: noop, - componentWillReceiveProps: noop, - componentWillMount: noop, - componentDidMount: noop, - componentWillUnmount: noop, - shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) { - return true; - }, + // getChildContext: _.noop, + // componentWillUpdate: _.noop, + // componentDidUpdate: _.noop, + // componentWillReceiveProps: _.noop, + // componentWillMount: _.noop, + // componentDidMount: _.noop, + // componentWillUnmount: _.noop, + // shouldComponentUpdate(nextProps, nextState) { + // return true + // }, forceUpdate: function forceUpdate(callback) { var $updater = this.$updater; var $cache = this.$cache; @@ -1369,7 +1294,9 @@ Component.prototype = { var vtree = $cache.vtree; $cache.props = $cache.state = $cache.context = null; $updater.isPending = true; - this.componentWillUpdate(nextProps, nextState, nextContext); + if (this.componentWillUpdate) { + this.componentWillUpdate(nextProps, nextState, nextContext); + } this.state = nextState; this.props = nextProps; this.context = nextContext; @@ -1382,7 +1309,9 @@ Component.prototype = { $cache.vtree = nextVtree; $cache.node = newNode; clearPendingComponents(); - this.componentDidUpdate(props, state, context); + if (this.componentDidUpdate) { + this.componentDidUpdate(props, state, context); + } if (callback) { callback.call(this); } @@ -1410,19 +1339,21 @@ Component.prototype = { } }; -var updatePropsAndState = function updatePropsAndState(component, props, state, context) { - component.state = state; - component.props = props; - component.context = context || {}; -}; - var shouldUpdate = function shouldUpdate(component, nextProps, nextState, nextContext, callback) { - var shouldComponentUpdate = component.shouldComponentUpdate(nextProps, nextState, nextContext); + var shouldComponentUpdate = true; + if (component.shouldComponentUpdate) { + shouldComponentUpdate = component.shouldComponentUpdate(nextProps, nextState, nextContext); + } if (shouldComponentUpdate === false) { - updatePropsAndState(component, nextProps, nextState, nextContext); + component.props = nextProps; + component.state = nextState; + component.context = nextContext || {}; return; } - updatePropsAndState(component.$cache, nextProps, nextState, nextContext); + var cache = component.$cache; + cache.props = nextProps; + cache.state = nextState; + cache.context = nextContext || {}; component.forceUpdate(callback); }; @@ -1621,6 +1552,76 @@ var ReactDOM = Object.freeze({ findDOMNode: findDOMNode }); +var isValidElement = function isValidElement(obj) { + return obj != null && !!obj.vtype; +}; + +var cloneElement = function cloneElement(originElem, props) { + for (var _len = arguments.length, children = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + children[_key - 2] = arguments[_key]; + } + + var type = originElem.type; + var key = originElem.key; + var ref = originElem.ref; + + var newProps = extend(extend({ key: key, ref: ref }, originElem.props), props); + var vnode = createElement.apply(undefined, [type, newProps].concat(children)); + if (vnode.ref === originElem.ref) { + vnode.refs = originElem.refs; + } + return vnode; +}; + +var createFactory = function createFactory(type) { + var factory = function factory() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + return createElement.apply(undefined, [type].concat(args)); + }; + factory.type = type; + return factory; +}; + +var createElement = function createElement(type, props) { + for (var _len3 = arguments.length, children = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { + children[_key3 - 2] = arguments[_key3]; + } + + var createVnode = undefined; + switch (true) { + case isStr(type): + createVnode = createVelem; + break; + case isComponent(type): + createVnode = createVcomponent; + break; + case isStatelessComponent(type): + createVnode = createVstatelessComponent; + break; + default: + throw new Error('React.createElement: unexpect type [ ' + type + ' ]'); + } + var key = null; + var ref = null; + if (props != null) { + if (props.key !== undefined) { + key = '' + props.key; + delete props.key; + } + if (props.ref !== undefined) { + ref = props.ref; + delete props.ref; + } + } + var vnode = createVnode(type, mergeProps(props, children, type.defaultProps)); + vnode.key = key; + vnode.ref = ref; + return vnode; +}; + var tagNames = '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'; var DOM = {}; eachItem(tagNames.split('|'), function (tagName) { diff --git a/dist/react-lite.js b/dist/react-lite.js index de27376..7b0e083 100644 --- a/dist/react-lite.js +++ b/dist/react-lite.js @@ -1,5 +1,5 @@ /*! - * react-lite.js v0.0.28 + * react-lite.js v0.0.29 * (c) 2016 Jade Gu * Released under the MIT License. */ @@ -316,81 +316,6 @@ oncontextmenu: TRUE }; - var isValidElement = function isValidElement(obj) { - return obj != null && !!obj.vtype; - }; - - var cloneElement = function cloneElement(originElem, props) { - for (var _len = arguments.length, children = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - children[_key - 2] = arguments[_key]; - } - - var type = originElem.type; - var key = originElem.key; - var ref = originElem.ref; - - var newProps = extend(extend({ key: key, ref: ref }, originElem.props), props); - var vnode = createElement.apply(undefined, [type, newProps].concat(children)); - if (vnode.ref === originElem.ref) { - vnode.refs = originElem.refs; - } - return vnode; - }; - - var createFactory = function createFactory(type) { - var factory = function factory() { - for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; - } - - return createElement.apply(undefined, [type].concat(args)); - }; - factory.type = type; - return factory; - }; - - var createElement = function createElement(type, props) { - for (var _len3 = arguments.length, children = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { - children[_key3 - 2] = arguments[_key3]; - } - - var createVnode = undefined; - switch (true) { - case isStr(type): - createVnode = createVelem; - break; - case isComponent(type): - createVnode = createVcomponent; - break; - case isStatelessComponent(type): - createVnode = createVstatelessComponent; - break; - default: - throw new Error('React.createElement: unexpect type [ ' + type + ' ]'); - } - var key = null; - var ref = null; - var hasRef = false; - if (props != null) { - if (props.key !== undefined) { - key = '' + props.key; - delete props.key; - } - if (props.ref !== undefined) { - ref = props.ref; - delete props.ref; - hasRef = true; - } - } - var vnode = createVnode(type, mergeProps(props, children, type.defaultProps)); - vnode.key = key; - vnode.ref = ref; - if (hasRef && createVnode !== createVstatelessComponent) { - handleVnodeWithRef(vnode); - } - return vnode; - }; - var diff = function diff(vnode, newVnode) { var type = undefined; switch (true) { @@ -444,7 +369,7 @@ var hasOwn = function hasOwn(obj, key) { return Object.prototype.hasOwnProperty.call(obj, key); }; - var noop$1 = function noop() {}; + var noop = function noop() {}; var identity = function identity(obj) { return obj; }; @@ -750,7 +675,8 @@ Object.freeze = identity; } - var noop$2 = noop$1; + var noop$1 = noop; + var refs = null; var initTree = function initTree(vtree, parentNode, parentContext) { var vtype = vtree.vtype; @@ -830,7 +756,8 @@ return { vtype: VNODE_TYPE.ELEMENT, type: type, - props: props + props: props, + refs: refs }; }; @@ -909,7 +836,7 @@ if (children) { var childNodes = node.childNodes; var $removeNode = removeNode; - removeNode = noop$2; + removeNode = noop$1; var len = children.length; var i = -1; while (len--) { @@ -984,7 +911,8 @@ id: getUid(), vtype: VNODE_TYPE.COMPONENT, type: type, - props: props + props: props, + refs: refs }; }; @@ -1001,8 +929,10 @@ cache.parentContext = parentContext; updater.isPending = true; component.props = component.props || props; - component.componentWillMount(); - component.state = updater.getState(); + if (component.componentWillMount) { + component.componentWillMount(); + component.state = updater.getState(); + } var vtree = renderComponent(component, parentContext); var node = initTree(vtree, parentNode, vtree.context); node.cache = node.cache || {}; @@ -1027,9 +957,11 @@ delete node.cache[id]; node.cache[newVcomponent.id] = component; cache.parentContext = parentContext; - updater.isPending = true; - component.componentWillReceiveProps(nextProps, componentContext); - updater.isPending = false; + if (component.componentWillReceiveProps) { + updater.isPending = true; + component.componentWillReceiveProps(nextProps, componentContext); + updater.isPending = false; + } updater.emitUpdate(nextProps, componentContext); updateRef(vcomponent, newVcomponent, component); return cache.node; @@ -1041,20 +973,16 @@ var cache = component.$cache; delete node.cache[id]; detachRef(vcomponent); - component.setState = component.forceUpdate = noop$2; - component.componentWillUnmount(); + component.setState = component.forceUpdate = noop$1; + if (component.componentWillUnmount) { + component.componentWillUnmount(); + } destroyTree(cache.vtree, node); delete component.setState; cache.isMounted = false; cache.node = cache.parentContext = cache.vtree = component.refs = component.context = null; }; - var setRefs = noop$2; - var handleVnodeWithRef = function handleVnodeWithRef(vnode) { - if (setRefs !== noop$2) { - setRefs(vnode); - } - }; var getContextByTypes = function getContextByTypes(curContext, contextTypes) { var context = {}; if (!contextTypes || !curContext) { @@ -1068,27 +996,23 @@ return context; }; - var bindRefs = function bindRefs(refs) { - return function (vnode) { - vnode.refs = vnode.refs || refs; - }; - }; - var renderComponent = function renderComponent(component, parentContext) { - setRefs = bindRefs(component.refs); + refs = component.refs; var vtree = component.render(); if (isUndefined(vtree)) { throw new Error('component can not render undefined'); } vtree = getVnode(vtree); - var curContext = component.getChildContext(); + var curContext = refs = null; + if (component.getChildContext) { + curContext = component.getChildContext(); + } if (curContext) { curContext = extend(extend({}, parentContext), curContext); } else { curContext = parentContext; } vtree.context = curContext; - setRefs = noop$2; return vtree; }; @@ -1104,7 +1028,9 @@ while (len--) { var component = components[++i]; var updater = component.$updater; - component.componentDidMount(); + if (component.componentDidMount) { + component.componentDidMount(); + } updater.isPending = false; updater.emitUpdate(); } @@ -1121,7 +1047,7 @@ break; case DIFF_TYPE.REPLACE: var $removeNode = removeNode; - removeNode = noop$2; + removeNode = noop$1; destroyTree(vtree, node); removeNode = $removeNode; newNode = initTree(newVtree, function (nextNode) { @@ -1153,7 +1079,7 @@ var getVnode = function getVnode(vnode) { if (vnode === null) { vnode = createVelem('noscript', {}); - } else if (!vnode.vtype) { + } else if (!vnode || !vnode.vtype) { vnode = createVtext(vnode); } return vnode; @@ -1342,19 +1268,18 @@ this.context = context || {}; } - var noop = noop$1; Component.prototype = { constructor: Component, - getChildContext: noop, - componentWillUpdate: noop, - componentDidUpdate: noop, - componentWillReceiveProps: noop, - componentWillMount: noop, - componentDidMount: noop, - componentWillUnmount: noop, - shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) { - return true; - }, + // getChildContext: _.noop, + // componentWillUpdate: _.noop, + // componentDidUpdate: _.noop, + // componentWillReceiveProps: _.noop, + // componentWillMount: _.noop, + // componentDidMount: _.noop, + // componentWillUnmount: _.noop, + // shouldComponentUpdate(nextProps, nextState) { + // return true + // }, forceUpdate: function forceUpdate(callback) { var $updater = this.$updater; var $cache = this.$cache; @@ -1373,7 +1298,9 @@ var vtree = $cache.vtree; $cache.props = $cache.state = $cache.context = null; $updater.isPending = true; - this.componentWillUpdate(nextProps, nextState, nextContext); + if (this.componentWillUpdate) { + this.componentWillUpdate(nextProps, nextState, nextContext); + } this.state = nextState; this.props = nextProps; this.context = nextContext; @@ -1386,7 +1313,9 @@ $cache.vtree = nextVtree; $cache.node = newNode; clearPendingComponents(); - this.componentDidUpdate(props, state, context); + if (this.componentDidUpdate) { + this.componentDidUpdate(props, state, context); + } if (callback) { callback.call(this); } @@ -1414,19 +1343,21 @@ } }; - var updatePropsAndState = function updatePropsAndState(component, props, state, context) { - component.state = state; - component.props = props; - component.context = context || {}; - }; - var shouldUpdate = function shouldUpdate(component, nextProps, nextState, nextContext, callback) { - var shouldComponentUpdate = component.shouldComponentUpdate(nextProps, nextState, nextContext); + var shouldComponentUpdate = true; + if (component.shouldComponentUpdate) { + shouldComponentUpdate = component.shouldComponentUpdate(nextProps, nextState, nextContext); + } if (shouldComponentUpdate === false) { - updatePropsAndState(component, nextProps, nextState, nextContext); + component.props = nextProps; + component.state = nextState; + component.context = nextContext || {}; return; } - updatePropsAndState(component.$cache, nextProps, nextState, nextContext); + var cache = component.$cache; + cache.props = nextProps; + cache.state = nextState; + cache.context = nextContext || {}; component.forceUpdate(callback); }; @@ -1625,6 +1556,76 @@ findDOMNode: findDOMNode }); + var isValidElement = function isValidElement(obj) { + return obj != null && !!obj.vtype; + }; + + var cloneElement = function cloneElement(originElem, props) { + for (var _len = arguments.length, children = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + children[_key - 2] = arguments[_key]; + } + + var type = originElem.type; + var key = originElem.key; + var ref = originElem.ref; + + var newProps = extend(extend({ key: key, ref: ref }, originElem.props), props); + var vnode = createElement.apply(undefined, [type, newProps].concat(children)); + if (vnode.ref === originElem.ref) { + vnode.refs = originElem.refs; + } + return vnode; + }; + + var createFactory = function createFactory(type) { + var factory = function factory() { + for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + return createElement.apply(undefined, [type].concat(args)); + }; + factory.type = type; + return factory; + }; + + var createElement = function createElement(type, props) { + for (var _len3 = arguments.length, children = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { + children[_key3 - 2] = arguments[_key3]; + } + + var createVnode = undefined; + switch (true) { + case isStr(type): + createVnode = createVelem; + break; + case isComponent(type): + createVnode = createVcomponent; + break; + case isStatelessComponent(type): + createVnode = createVstatelessComponent; + break; + default: + throw new Error('React.createElement: unexpect type [ ' + type + ' ]'); + } + var key = null; + var ref = null; + if (props != null) { + if (props.key !== undefined) { + key = '' + props.key; + delete props.key; + } + if (props.ref !== undefined) { + ref = props.ref; + delete props.ref; + } + } + var vnode = createVnode(type, mergeProps(props, children, type.defaultProps)); + vnode.key = key; + vnode.ref = ref; + return vnode; + }; + var tagNames = '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'; var DOM = {}; eachItem(tagNames.split('|'), function (tagName) { diff --git a/dist/react-lite.min.js b/dist/react-lite.min.js index cc465c5..c1e3b17 100644 --- a/dist/react-lite.min.js +++ b/dist/react-lite.min.js @@ -1,6 +1,6 @@ /*! - * react-lite.js v0.0.28 + * react-lite.js v0.0.29 * (c) 2016 Jade Gu * Released under the MIT License. */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.React=t()}(this,function(){"use strict";function e(e,t){if(!t)return e;for(var n=Object.keys(t),r=n.length;r--;)void 0!==t[n[r]]&&(e[n[r]]=t[n[r]]);return e}function t(e,t,n,r,i){var o=n;switch(T(e,t)){case s.UPDATE:o=me(e,t,n,r,i);break;case s.REMOVE:ye(e,n);break;case s.REPLACE:var a=Fe;Fe=he,ye(e,n),Fe=a,o=ve(t,function(e){return r.replaceChild(e,n)},i);break;case s.CREATE:o=ve(t,r,i)}return o}function n(e){this.instance=e,this.pendingStates=[],this.pendingCallbacks=[],this.isPending=!1,this.nextProps=this.nextContext=null,this.clearCallbacks=this.clearCallbacks.bind(this)}function r(e,t){this.$updater=new n(this),this.$cache={isMounted:!1},this.props=e,this.state={},this.refs={},this.context=t||{}}var i=!0,o="http://www.w3.org/1999/xlink",a="http://www.w3.org/XML/1998/namespace",c="http://www.w3.org/2000/svg",l={ELEMENT:1,COMPONENT:2,STATELESS_COMPONENT:3,TEXT:4},s={CREATE:1,REMOVE:2,REPLACE:3,UPDATE:4},u="liteid",p={clipPath:"clip-path",fillOpacity:"fill-opacity",fontFamily:"font-family",fontSize:"font-size",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",stopColor:"stop-color",stopOpacity:"stop-opacity",strokeDasharray:"stroke-dasharray",strokeLinecap:"stroke-linecap",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",textAnchor:"text-anchor",xlinkActuate:"xlink:actuate",xlinkArcrole:"xlink:arcrole",xlinkHref:"xlink:href",xlinkRole:"xlink:role",xlinkShow:"xlink:show",xlinkTitle:"xlink:title",xlinkType:"xlink:type",xmlBase:"xml:base",xmlLang:"xml:lang",xmlSpace:"xml:space",acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv",autoCompconste:"autocompconste",autoFocus:"autofocus",autoPlay:"autoplay",autoSave:"autosave",hrefLang:"hreflang",radioGroup:"radiogroup",spellCheck:"spellcheck",srcDoc:"srcdoc",srcSet:"srcset"},d={xlinkActuate:o,xlinkArcrole:o,xlinkHref:o,xlinkRole:o,xlinkShow:o,xlinkTitle:o,xlinkType:o,xmlBase:a,xmlLang:a,xmlSpace:a},f={type:i,clipPath:i,cx:i,cy:i,d:i,dx:i,dy:i,fill:i,fillOpacity:i,fontFamily:i,fontSize:i,fx:i,fy:i,gradientTransform:i,gradientUnits:i,markerEnd:i,markerMid:i,markerStart:i,offset:i,opacity:i,patternContentUnits:i,patternUnits:i,points:i,preserveAspectRatio:i,r:i,rx:i,ry:i,spreadMethod:i,stopColor:i,stopOpacity:i,stroke:i,strokeDasharray:i,strokeLinecap:i,strokeOpacity:i,strokeWidth:i,textAnchor:i,transform:i,version:i,viewBox:i,x1:i,x2:i,x:i,xlinkActuate:i,xlinkArcrole:i,xlinkHref:i,xlinkRole:i,xlinkShow:i,xlinkTitle:i,xlinkType:i,xmlBase:i,xmlLang:i,xmlSpace:i,y1:i,y2:i,y:i,allowFullScreen:i,allowTransparency:i,charSet:i,challenge:i,classID:i,cols:i,contextMenu:i,dateTime:i,form:i,formAction:i,formEncType:i,formMethod:i,formTarget:i,frameBorder:i,height:i,inputMode:i,is:i,keyParams:i,keyType:i,list:i,manifest:i,maxLength:i,media:i,minLength:i,nonce:i,role:i,rows:i,size:i,sizes:i,srcSet:i,width:i,wmode:i,about:i,datatype:i,inlist:i,prefix:i,property:i,resource:i,"typeof":i,vocab:i,autoCapitalize:i,autoCorrect:i,itemProp:i,itemType:i,itemID:i,itemRef:i,security:i,unselectable:i},h={nodeName:i,nodeValue:i,nodeType:i,parentNode:i,childNodes:i,classList:i,firstChild:i,lastChild:i,previousSibling:i,previousElementSibling:i,nextSibling:i,nextElementSibling:i,attributes:i,ownerDocument:i,namespaceURI:i,localName:i,baseURI:i,prefix:i,length:i,specified:i,tagName:i,offsetTop:i,offsetLeft:i,offsetWidth:i,offsetHeight:i,offsetParent:i,scrollWidth:i,scrollHeight:i,clientTop:i,clientLeft:i,clientWidth:i,clientHeight:i,x:i,y:i},v={animationIterationCount:i,boxFlex:i,boxFlexGroup:i,boxOrdinalGroup:i,columnCount:i,flex:i,flexGrow:i,flexPositive:i,flexShrink:i,flexNegative:i,flexOrder:i,fontWeight:i,lineClamp:i,lineHeight:i,opacity:i,order:i,orphans:i,tabSize:i,widows:i,zIndex:i,zoom:i,fillOpacity:i,stopOpacity:i,strokeDashoffset:i,strokeOpacity:i,strokeWidth:i},m={value:i,checked:i},y={onDoubleClick:"ondblclick"},g={onmouseleave:i,onmouseenter:i,onload:i,onunload:i,onscroll:i,onfocus:i,onblur:i,onrowexit:i,onbeforeunload:i,onstop:i,ondragdrop:i,ondragenter:i,ondragexit:i,ondraggesture:i,ondragover:i,oncontextmenu:i},x=function(e){return null!=e&&!!e.vtype},k=function(t,n){for(var r=arguments.length,i=Array(r>2?r-2:0),o=2;r>o;o++)i[o-2]=arguments[o];var a=t.type,c=t.key,l=t.ref,s=e(e({key:c,ref:l},t.props),n),u=E.apply(void 0,[a,s].concat(i));return u.ref===t.ref&&(u.refs=t.refs),u},b=function(e){var t=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return E.apply(void 0,[e].concat(n))};return t.type=e,t},E=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;n>i;i++)r[i-2]=arguments[i];var o=void 0;switch(!0){case O(e):o=Ee;break;case A(e):o=Le;break;case L(e):o=Pe;break;default:throw new Error("React.createElement: unexpect type [ "+e+" ]")}var a=null,c=null,l=!1;null!=t&&(void 0!==t.key&&(a=""+t.key,delete t.key),void 0!==t.ref&&(c=t.ref,delete t.ref,l=!0));var s=o(e,F(t,r,e.defaultProps));return s.key=a,s.ref=c,l&&o!==Pe&&$e(s),s},T=function(e,t){var n=void 0;switch(!0){case e===t:return n;case M(t):n=s.REMOVE;break;case M(e):n=s.CREATE;break;case e.type!==t.type:n=s.REPLACE;break;case null!==t.key:n=null===e.key||t.key!==e.key?s.REPLACE:s.UPDATE;break;case null!==e.key:n=s.REPLACE;break;default:n=s.UPDATE}return n},C=function(e){return function(t){return null!=t&&Object.prototype.toString.call(t)==="[object "+e+"]"}},S=C("Object"),O=C("String"),P=C("Function"),N=C("Boolean"),w=Array.isArray||C("Array"),M=function(e){return void 0===e},A=function(e){return e&&e.prototype&&"forceUpdate"in e.prototype},L=function(e){return P(e)&&(!e.prototype||!("forceUpdate"in e.prototype))},U=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},D=function(){},R=function(e){return e},_=function(e,t){return function(){return e.apply(this,arguments),t.apply(this,arguments)}},$=function Rt(e,t,n){var r=e.length,i=-1;for(n=n||[];r--;){var o=e[++i];w(o)?Rt(o,t,n):M(o)||N(o)||n.push(t(o,n.length)||o)}return n},I=function(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)},W=function(e,t){for(var n in e)U(e,n)&&t(e[n],n)},z=function(e,t,n){var r={};for(var i in e)U(e,i)&&(r[i]=!0,n(i));for(var i in t)U(t,i)&&r[i]!==!0&&n(i)},H=0,j=function(){return++H},F=function(t,n,r){var i=e(e({},r),t),o=n.length;return 1===o?i.children=n[0]:o>1&&(i.children=n),i},B=/^on/i,q=function(e){return"dangerouslySetInnerHTML"===e},G=function(e){return"style"===e},X=function(e,t,n){var r=t;switch(t=p[t]||t,!0){case"children"===t:break;case B.test(t):nt(e,t,n);break;case G(t):re(e,n);break;case q(t):n&&null!=n.__html&&(e.innerHTML=n.__html);break;case t in e&&f[r]!==!0:h[t]!==!0&&("title"===t&&null==n&&(n=""),e[t]=n);break;default:null==n?e.removeAttribute(t):d[r]===!0?e.setAttributeNS(t,n):e.setAttribute(t,n)}},V=function(e,t){for(var n in t)U(t,n)&&X(e,n,t[n])},Y=function(e,t){for(var n in t)U(t,n)&&J(e,n,t[n])},J=function(e,t,n){switch(t=p[t]||t,!0){case"children"===t:break;case B.test(t):rt(e,t);break;case G(t):ne(e,n);break;case q(t):e.innerHTML="";break;case f[t]===!0||!(t in e):e.removeAttribute(t);break;case P(n):e[t]=null;break;case O(n):e[t]="";break;case N(n):e[t]=!1;break;default:try{e[t]=void 0,delete e[t]}catch(r){}}},K=null,Q=null,Z=null,ee=function(e){if("children"!==e){var t=Q[e],n=1==m[e]?Z[e]:K[e];if(t!==n){if(M(t))return void J(Z,e,n);if(G(e))le(Z,n,t);else if(q(e)){var r=n&&n.__html,i=t&&t.__html;null!=i&&i!==r&&(Z.innerHTML=i)}else X(Z,e,t)}}},te=function(e,t,n){if(t!==n){if(!t&&n)return void V(e,n);if(!n&&t)return void Y(e,t);Z=e,K=t,Q=n,z(t,n,ee),Z=K=Q=null}},ne=function(e,t){if(S(t)){var n=e.style;for(var r in t)U(t,r)&&(n[r]="")}},re=function(e,t){if(S(t)){var n=e.style;for(var r in t)U(t,r)&&fe(n,r,t[r])}},ie=null,oe=null,ae=null,ce=function(e){var t=ae[e],n=oe[e];t!==n&&fe(ie,e,t)},le=function(e,t,n){t!==n&&(!n&&t?ne(e,t):n&&!t?re(e,n):(ie=e.style,oe=t,ae=n,z(t,n,ce),ie=oe=ae=null))},se={},ue=["Webkit","ms","Moz","O"],pe=function(e,t){return e+t.charAt(0).toUpperCase()+t.substring(1)};W(v,function(e,t){I(ue,function(e){return se[pe(e,t)]=!0})}),W(se,function(e,t){v[t]=e});var de=/^-?\d+(\.\d+)?$/,fe=function(e,t,n){!v[t]&&de.test(n)?e[t]=n+"px":(t="float"===t?"cssFloat":t,n=null==n||N(n)?"":n,e[t]=n)};Object.freeze||(Object.freeze=R);var he=D,ve=function(e,t,n){var r=e.vtype,i=void 0;return r===l.TEXT?i=xe(e,t,n):r===l.ELEMENT?i=Te(e,t,n):r===l.COMPONENT?i=Ue(e,t,n):r===l.STATELESS_COMPONENT&&(i=Ne(e,t,n)),i},me=function(e,t,n,r,i){var o=e.vtype,a=void 0;return o===l.TEXT?a=ke(e,t,n,r,i):o===l.ELEMENT?a=Ce(e,t,n,r,i):o===l.COMPONENT?a=De(e,t,n,r,i):o===l.STATELESS_COMPONENT&&(a=we(e,t,n,r,i)),a},ye=function(e,t){var n=e.vtype;n===l.TEXT?t=be(e,t):n===l.ELEMENT?t=Se(e,t):n===l.COMPONENT?t=Re(e,t):n===l.STATELESS_COMPONENT&&(t=Me(e,t))},ge=function(e){return{vtype:l.TEXT,text:e}},xe=function(e,t){var n=document.createTextNode(e.text);return Be(t,n),n},ke=function(e,t,n){return t.text!==e.text&&n.replaceData(0,n.length,t.text),n},be=function(e){Fe(e)},Ee=function(e,t){return{vtype:l.ELEMENT,type:e,props:t}},Te=function(e,t,n){var r=e.type,i=e.props,o=void 0;o="svg"===r||t.namespaceURI===c?document.createElementNS(c,r):document.createElement(r);var a=i.children=Oe(i.children,qe);if(a)for(var l=a.length,s=-1;l--;)ve(a[++s],o,n);return V(o,i),Be(t,o),Xe(e,o),o},Ce=function(e,n,r,i,o){var a=e.props,c=n.props,l=a.dangerouslySetInnerHTML&&a.dangerouslySetInnerHTML.__html,s=a.children;if(null==l&&s){var u=r.childNodes,p=c.children=Oe(c.children,qe);if(p)for(var d=p.length,f=-1;d--;){var h=p[++f],v=s[f];v?t(v,h,u[f],r,o):ve(h,r,o)}for(var m=s.length,y=p&&p.length||0;m>y;)m-=1,ye(s[m],u[m]);te(r,a,c)}else{te(r,a,c);var p=c.children=Oe(c.children,qe);if(p)for(var d=p.length,f=-1;d--;)ve(p[++f],r,o)}return Ye(e,n,r),r},Se=function(e,t){var n=e.props.children;if(n){var r=t.childNodes,i=Fe;Fe=he;for(var o=n.length,a=-1;o--;)ye(n[++a],r[a]);Fe=i}Ve(e),Fe(t)},Oe=function(e,t){return w(e)?$(e,t):M(e)||N(e)?void 0:[t(e,0)]},Pe=function(e,t){return{id:j(),vtype:l.STATELESS_COMPONENT,type:e,props:t}},Ne=function(e,t,n){var r=Ae(e,n),i=ve(r,t,n);return i.cache=i.cache||{},i.cache[e.id]=r,i},we=function(n,r,i,o,a){var c=n.id,l=i.cache[c];delete i.cache[c];var s=Ae(r,a),u=t(l,s,i,o,a);return u.cache=u.cache||{},u.cache[r.id]=s,u!==i&&e(u.cache,i.cache),u},Me=function(e,t){var n=e.id,r=t.cache[n];delete t.cache[n],ye(r,t)},Ae=function(e,t){var n=e.type,r=e.props,i=Ie(t,n.contextTypes),o=n(r,i);return o&&o.render&&(o=o.render()),qe(o)},Le=function(e,t){return{id:j(),vtype:l.COMPONENT,type:e,props:t}},Ue=function(e,t,n){var r=e.type,i=e.props,o=e.id,a=Ie(n,r.contextTypes),c=new r(i,a),l=c.$updater,s=c.$cache;s.parentContext=n,l.isPending=!0,c.props=c.props||i,c.componentWillMount(),c.state=l.getState();var u=ze(c,n),p=ve(u,t,u.context);return p.cache=p.cache||{},p.cache[o]=c,s.vtree=u,s.node=p,s.isMounted=!0,He.push(c),Xe(e,c),p},De=function(e,t,n,r,i){var o=e.id,a=n.cache[o],c=a.$updater,l=a.$cache,s=t.type,u=t.props,p=Ie(i,s.contextTypes);return delete n.cache[o],n.cache[t.id]=a,l.parentContext=i,c.isPending=!0,a.componentWillReceiveProps(u,p),c.isPending=!1,c.emitUpdate(u,p),Ye(e,t,a),l.node},Re=function(e,t){var n=e.id,r=t.cache[n],i=r.$cache;delete t.cache[n],Ve(e),r.setState=r.forceUpdate=he,r.componentWillUnmount(),ye(i.vtree,t),delete r.setState,i.isMounted=!1,i.node=i.parentContext=i.vtree=r.refs=r.context=null},_e=he,$e=function(e){_e!==he&&_e(e)},Ie=function(e,t){var n={};if(!t||!e)return n;for(var r in t)t.hasOwnProperty(r)&&(n[r]=e[r]);return n},We=function(e){return function(t){t.refs=t.refs||e}},ze=function(t,n){_e=We(t.refs);var r=t.render();if(M(r))throw new Error("component can not render undefined");r=qe(r);var i=t.getChildContext();return i=i?e(e({},n),i):n,r.context=i,_e=he,r},He=[],je=function(){var e=He,t=e.length;if(t){He=[];for(var n=-1;t--;){var r=e[++n],i=r.$updater;r.componentDidMount(),i.isPending=!1,i.emitUpdate()}}},Fe=function(e){e&&e.parentNode&&e.parentNode.removeChild(e)},Be=function(e,t){P(e)?e(t):e.appendChild(t)},qe=function(e){return null===e?e=Ee("noscript",{}):e.vtype||(e=ge(e)),e},Ge=function(){return this},Xe=function(e,t){var n=e.ref,r=e.refs;e.vtype;r&&null!=n&&t&&(t.nodeName&&!t.getDOMNode&&(t.getDOMNode=Ge),P(n)?n(t):r[n]=t)},Ve=function(e){var t=e.ref,n=e.refs;n&&null!=t&&(P(t)?t(null):delete n[t])},Ye=function(e,t,n){if(!e.refs)return void Xe(t,n);if(!t.refs)return void Ve(e);if(e.refs!==t.refs)return Ve(e),void Xe(t,n);var r=e.ref,i=t.ref;null==i?Ve(e):r!==i&&(Ve(e),Xe(t,n))},Je={updaters:[],isPending:!1,add:function(e){this.updaters.push(e)},batchUpdate:function(){if(!this.isPending){this.isPending=!0;for(var e=this.updaters,t=void 0;t=e.pop();)t.updateComponent();this.isPending=!1}}};n.prototype={emitUpdate:function(e,t){this.nextProps=e,this.nextContext=t,e||!Je.isPending?this.updateComponent():Je.add(this)},updateComponent:function(){var e=this.instance,t=this.pendingStates,n=this.nextProps,r=this.nextContext;(n||t.length>0)&&(n=n||e.props,r=r||e.context,this.nextProps=this.nextContext=null,Ze(e,n,this.getState(),r,this.clearCallbacks))},addState:function(e){e&&(this.pendingStates.push(e),this.isPending||this.emitUpdate())},replaceState:function(e){var t=this.pendingStates;t.pop(),t.push([e])},getState:function(){var t=this.instance,n=this.pendingStates,r=t.state,i=t.props;return n.length&&(r=e({},r),I(n,function(n){return w(n)?void(r=e({},n[0])):(P(n)&&(n=n.call(t,r,i)),void e(r,n))}),n.length=0),r},clearCallbacks:function(){var e=this.pendingCallbacks,t=this.instance;e.length>0&&(this.pendingCallbacks=[],I(e,function(e){return e.call(t)}))},addCallback:function(e){P(e)&&this.pendingCallbacks.push(e)}};var Ke=D;r.prototype={constructor:r,getChildContext:Ke,componentWillUpdate:Ke,componentDidUpdate:Ke,componentWillReceiveProps:Ke,componentWillMount:Ke,componentDidMount:Ke,componentWillUnmount:Ke,shouldComponentUpdate:function(e,t){return!0},forceUpdate:function(n){var r=this.$updater,i=this.$cache,o=this.props,a=this.state,c=this.context;if(!r.isPending&&i.isMounted){var l=i.props||o,s=i.state||a,u=i.context||{},p=i.parentContext,d=i.node,f=i.vtree;i.props=i.state=i.context=null,r.isPending=!0,this.componentWillUpdate(l,s,u),this.state=s,this.props=l,this.context=u;var h=ze(this,p),v=t(f,h,d,d.parentNode,h.context);v!==d&&(v.cache=v.cache||{},e(v.cache,d.cache)),i.vtree=h,i.node=v,je(),this.componentDidUpdate(o,a,c),n&&n.call(this),r.isPending=!1,r.emitUpdate()}},setState:function(e,t){var n=this.$updater;n.addCallback(t),n.addState(e)},replaceState:function(e,t){var n=this.$updater;n.addCallback(t),n.replaceState(e)},getDOMNode:function(){var e=this.$cache.node;return e&&"NOSCRIPT"===e.tagName?null:e},isMounted:function(){return this.$cache.isMounted}};var Qe=function(e,t,n,r){e.state=n,e.props=t,e.context=r||{}},Ze=function(e,t,n,r,i){var o=e.shouldComponentUpdate(t,n,r);return o===!1?void Qe(e,t,n,r):(Qe(e.$cache,t,n,r),void e.forceUpdate(i))},et=function(e){return e=y[e]||e,e.toLowerCase()},tt={},nt=function _t(e,t,n){if(t=et(t),g[t]===!0)return void(e[t]=n);var r=e.eventStore||(e.eventStore={});r[t]=n,tt[t]||(document.addEventListener(t.substr(2),it),tt[t]=!0),"onchange"===t&&_t(e,"oninput",n)},rt=function(e,t){if(t=et(t),g[t]===!0)return void(e[t]=null);var n=e.eventStore||(e.eventStore={});delete n[t],"onchange"===t&&delete n.oninput},it=function(e){var t=e.target,n=e.type,r="on"+n,i=void 0;for(Je.isPending=!0;t;){var o=t,a=o.eventStore,c=a&&a[r];if(c){if(i||(i=ot(e)),i.currentTarget=t,c.call(t,i),i.$cancalBubble)break;t=t.parentNode}else t=t.parentNode}Je.isPending=!1,Je.batchUpdate()},ot=function(e){var t={},n=function(){return t.$cancalBubble=!0};t.nativeEvent=e;for(var r in e)"function"!=typeof e[r]?t[r]=e[r]:"stopPropagation"===r||"stopImmediatePropagation"===r?t[r]=n:t[r]=e[r].bind(e);return t},at={},ct={},lt=function $t(e,n,r,o){if(!e.vtype)throw new Error("cannot render "+e+" to container");var a=n[u]||(n[u]=j()),c=at[a];if(c)return void(c===i?at[a]=c=[e,r,o]:(c[0]=e,c[2]=o,r&&(c[1]=c[1]?_(c[1],r):r)));at[a]=i,ct[a]?t(ct[a],e,n.firstChild,n,o):(n.innerHTML="",ve(e,n,o)),ct[a]=e;var s=Je.isPending;Je.isPending=!0,je(!0),c=at[a],delete at[a];var p=null;return w(c)?p=$t(c[0],n,c[1],c[2]):e.vtype===l.ELEMENT?p=n.firstChild:e.vtype===l.COMPONENT&&(p=n.firstChild.cache[e.id]),s||(Je.isPending=!1,Je.batchUpdate()),r&&r.call(p),p},st=function(e,t,n){return lt(e,t,n)},ut=function(e,t,n,r){var i=e.vtree?e.vtree.context:e.$cache.parentContext;return lt(t,n,r,i)},pt=function(e){if(!e.nodeName)throw new Error("expect node");var t=e[u];return ct[t]?(ye(ct[t],e.firstChild),delete ct[t],!0):!1},dt=function(e){if(null==e)return null;if(e.nodeName)return e;var t=e;if(t.getDOMNode&&t.$cache.isMounted)return t.getDOMNode();throw new Error("findDOMNode can not find Node")},ft=Object.freeze({render:st,unstable_renderSubtreeIntoContainer:ut,unmountComponentAtNode:pt,findDOMNode:dt}),ht="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",vt={};I(ht.split("|"),function(e){vt[e]=b(e)});var mt=function It(){return It};mt.isRequired=mt;var yt={array:mt,bool:mt,func:mt,number:mt,object:mt,string:mt,any:mt,arrayOf:mt,element:mt,instanceOf:mt,node:mt,objectOf:mt,oneOf:mt,oneOfType:mt,shape:mt},gt=function(e){if(x(e))return e;throw new Error("expect only one child")},xt=function(e,t,n){return null==e?e:void(w(e)?$(e,function(e,r){t.call(n,e,r)}):t.call(n,e,0))},kt=function(e,t,n){if(null==e)return e;var r=[],i={};xt(e,function(e,o){var a={};a.child=t.call(n,e,o)||e,a.isEqual=a.child===e;var c=a.key=Tt(e,o);i.hasOwnProperty(c)?i[c]+=1:i[c]=0,a.index=i[c],r.push(a)});var o=[];return I(r,function(e){var t=e.child,n=e.key,r=e.index,a=e.isEqual;if(null!=t&&!N(t)){if(!x(t)||null==n)return void o.push(t);0!==i[n]&&(n+=":"+r),a||(n=St(t.key||"")+"/"+n),t=k(t,{key:n}),o.push(t)}}),o},bt=function Wt(e){var Wt=0;return xt(e,function(){Wt++}),Wt},Et=function(e){return kt(e,R)||[]},Tt=function(e,t){var n=void 0;return n=x(e)&&O(e.key)?".$"+e.key:"."+t.toString(36)},Ct=/\/(?!\/)/g,St=function(e){return(""+e).replace(Ct,"//")},Ot=Object.freeze({only:gt,forEach:xt,map:kt,count:bt,toArray:Et}),Pt=function zt(e,t){I(e,function(e){e&&(w(e.mixins)&&zt(e.mixins,t),t(e))})},Nt=function(e,t){W(t,function(t,n){if("getInitialState"===n)return void e.$getInitialStates.push(t);var r=e[n];P(r)&&P(t)?e[n]=_(r,t):e[n]=t})},wt=function(t,n){S(n.propTypes)&&e(t.propTypes,n.propTypes),S(n.contextTypes)&&e(t.contextTypes,n.contextTypes),P(n.getDefaultProps)&&e(t.defaultProps,n.getDefaultProps()),S(n.statics)&&e(t,n.statics)},Mt=function(e,t){W(t,function(t,n){P(t)&&(e[n]=t.bind(e))})},At=function(){};At.prototype=r.prototype;var Lt=function(){var t=this,n={},r=this.setState;return this.setState=At,I(this.$getInitialStates,function(r){P(r)&&e(n,r.call(t))}),this.setState=r,n},Ut=function(e){function t(n,i){r.call(this,n,i),this.constructor=t,e.autobind!==!1&&Mt(this,t.prototype),this.state=this.getInitialState()||this.state}if(!P(e.render))throw new Error("createClass: spec.render is not function");var n=e.mixins||[],i=n.concat(e);e.mixins=null,t.displayName=e.displayName,t.contextTypes={},t.propTypes={},t.defaultProps={};var o=t.prototype=new At;return o.$getInitialStates=[],Pt(i,function(e){Nt(o,e),wt(t,e)}),o.getInitialState=Lt,e.mixins=n,t},Dt=e({version:"0.14.7",cloneElement:k,isValidElement:x,createElement:E,createFactory:b,Component:r,createClass:Ut,Children:Ot,PropTypes:yt,DOM:vt},ft);return Dt.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ft,Dt}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.React=t()}(this,function(){"use strict";function e(e,t){if(!t)return e;for(var n=Object.keys(t),r=n.length;r--;)void 0!==t[n[r]]&&(e[n[r]]=t[n[r]]);return e}function t(e,t,n,r,i){var o=n;switch(x(e,t)){case s.UPDATE:o=fe(e,t,n,r,i);break;case s.REMOVE:he(e,n);break;case s.REPLACE:var a=$e;$e=ue,he(e,n),$e=a,o=de(t,function(e){return r.replaceChild(e,n)},i);break;case s.CREATE:o=de(t,r,i)}return o}function n(e){this.instance=e,this.pendingStates=[],this.pendingCallbacks=[],this.isPending=!1,this.nextProps=this.nextContext=null,this.clearCallbacks=this.clearCallbacks.bind(this)}function r(e,t){this.$updater=new n(this),this.$cache={isMounted:!1},this.props=e,this.state={},this.refs={},this.context=t||{}}var i=!0,o="http://www.w3.org/1999/xlink",a="http://www.w3.org/XML/1998/namespace",c="http://www.w3.org/2000/svg",l={ELEMENT:1,COMPONENT:2,STATELESS_COMPONENT:3,TEXT:4},s={CREATE:1,REMOVE:2,REPLACE:3,UPDATE:4},u="liteid",p={clipPath:"clip-path",fillOpacity:"fill-opacity",fontFamily:"font-family",fontSize:"font-size",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",stopColor:"stop-color",stopOpacity:"stop-opacity",strokeDasharray:"stroke-dasharray",strokeLinecap:"stroke-linecap",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",textAnchor:"text-anchor",xlinkActuate:"xlink:actuate",xlinkArcrole:"xlink:arcrole",xlinkHref:"xlink:href",xlinkRole:"xlink:role",xlinkShow:"xlink:show",xlinkTitle:"xlink:title",xlinkType:"xlink:type",xmlBase:"xml:base",xmlLang:"xml:lang",xmlSpace:"xml:space",acceptCharset:"accept-charset",className:"class",htmlFor:"for",httpEquiv:"http-equiv",autoCompconste:"autocompconste",autoFocus:"autofocus",autoPlay:"autoplay",autoSave:"autosave",hrefLang:"hreflang",radioGroup:"radiogroup",spellCheck:"spellcheck",srcDoc:"srcdoc",srcSet:"srcset"},d={xlinkActuate:o,xlinkArcrole:o,xlinkHref:o,xlinkRole:o,xlinkShow:o,xlinkTitle:o,xlinkType:o,xmlBase:a,xmlLang:a,xmlSpace:a},f={type:i,clipPath:i,cx:i,cy:i,d:i,dx:i,dy:i,fill:i,fillOpacity:i,fontFamily:i,fontSize:i,fx:i,fy:i,gradientTransform:i,gradientUnits:i,markerEnd:i,markerMid:i,markerStart:i,offset:i,opacity:i,patternContentUnits:i,patternUnits:i,points:i,preserveAspectRatio:i,r:i,rx:i,ry:i,spreadMethod:i,stopColor:i,stopOpacity:i,stroke:i,strokeDasharray:i,strokeLinecap:i,strokeOpacity:i,strokeWidth:i,textAnchor:i,transform:i,version:i,viewBox:i,x1:i,x2:i,x:i,xlinkActuate:i,xlinkArcrole:i,xlinkHref:i,xlinkRole:i,xlinkShow:i,xlinkTitle:i,xlinkType:i,xmlBase:i,xmlLang:i,xmlSpace:i,y1:i,y2:i,y:i,allowFullScreen:i,allowTransparency:i,charSet:i,challenge:i,classID:i,cols:i,contextMenu:i,dateTime:i,form:i,formAction:i,formEncType:i,formMethod:i,formTarget:i,frameBorder:i,height:i,inputMode:i,is:i,keyParams:i,keyType:i,list:i,manifest:i,maxLength:i,media:i,minLength:i,nonce:i,role:i,rows:i,size:i,sizes:i,srcSet:i,width:i,wmode:i,about:i,datatype:i,inlist:i,prefix:i,property:i,resource:i,"typeof":i,vocab:i,autoCapitalize:i,autoCorrect:i,itemProp:i,itemType:i,itemID:i,itemRef:i,security:i,unselectable:i},h={nodeName:i,nodeValue:i,nodeType:i,parentNode:i,childNodes:i,classList:i,firstChild:i,lastChild:i,previousSibling:i,previousElementSibling:i,nextSibling:i,nextElementSibling:i,attributes:i,ownerDocument:i,namespaceURI:i,localName:i,baseURI:i,prefix:i,length:i,specified:i,tagName:i,offsetTop:i,offsetLeft:i,offsetWidth:i,offsetHeight:i,offsetParent:i,scrollWidth:i,scrollHeight:i,clientTop:i,clientLeft:i,clientWidth:i,clientHeight:i,x:i,y:i},v={animationIterationCount:i,boxFlex:i,boxFlexGroup:i,boxOrdinalGroup:i,columnCount:i,flex:i,flexGrow:i,flexPositive:i,flexShrink:i,flexNegative:i,flexOrder:i,fontWeight:i,lineClamp:i,lineHeight:i,opacity:i,order:i,orphans:i,tabSize:i,widows:i,zIndex:i,zoom:i,fillOpacity:i,stopOpacity:i,strokeDashoffset:i,strokeOpacity:i,strokeWidth:i},m={value:i,checked:i},y={onDoubleClick:"ondblclick"},g={onmouseleave:i,onmouseenter:i,onload:i,onunload:i,onscroll:i,onfocus:i,onblur:i,onrowexit:i,onbeforeunload:i,onstop:i,ondragdrop:i,ondragenter:i,ondragexit:i,ondraggesture:i,ondragover:i,oncontextmenu:i},x=function(e,t){var n=void 0;switch(!0){case e===t:return n;case O(t):n=s.REMOVE;break;case O(e):n=s.CREATE;break;case e.type!==t.type:n=s.REPLACE;break;case null!==t.key:n=null===e.key||t.key!==e.key?s.REPLACE:s.UPDATE;break;case null!==e.key:n=s.REPLACE;break;default:n=s.UPDATE}return n},k=function(e){return function(t){return null!=t&&Object.prototype.toString.call(t)==="[object "+e+"]"}},b=k("Object"),E=k("String"),T=k("Function"),C=k("Boolean"),S=Array.isArray||k("Array"),O=function(e){return void 0===e},P=function(e){return e&&e.prototype&&"forceUpdate"in e.prototype},N=function(e){return T(e)&&(!e.prototype||!("forceUpdate"in e.prototype))},w=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},M=function(){},A=function(e){return e},L=function(e,t){return function(){return e.apply(this,arguments),t.apply(this,arguments)}},U=function At(e,t,n){var r=e.length,i=-1;for(n=n||[];r--;){var o=e[++i];S(o)?At(o,t,n):O(o)||C(o)||n.push(t(o,n.length)||o)}return n},D=function(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)},R=function(e,t){for(var n in e)w(e,n)&&t(e[n],n)},_=function(e,t,n){var r={};for(var i in e)w(e,i)&&(r[i]=!0,n(i));for(var i in t)w(t,i)&&r[i]!==!0&&n(i)},$=0,I=function(){return++$},W=function(t,n,r){var i=e(e({},r),t),o=n.length;return 1===o?i.children=n[0]:o>1&&(i.children=n),i},z=/^on/i,H=function(e){return"dangerouslySetInnerHTML"===e},j=function(e){return"style"===e},F=function(e,t,n){var r=t;switch(t=p[t]||t,!0){case"children"===t:break;case z.test(t):Ve(e,t,n);break;case j(t):Z(e,n);break;case H(t):n&&null!=n.__html&&(e.innerHTML=n.__html);break;case t in e&&f[r]!==!0:h[t]!==!0&&("title"===t&&null==n&&(n=""),e[t]=n);break;default:null==n?e.removeAttribute(t):d[r]===!0?e.setAttributeNS(t,n):e.setAttribute(t,n)}},B=function(e,t){for(var n in t)w(t,n)&&F(e,n,t[n])},q=function(e,t){for(var n in t)w(t,n)&&G(e,n,t[n])},G=function(e,t,n){switch(t=p[t]||t,!0){case"children"===t:break;case z.test(t):Ye(e,t);break;case j(t):Q(e,n);break;case H(t):e.innerHTML="";break;case f[t]===!0||!(t in e):e.removeAttribute(t);break;case T(n):e[t]=null;break;case E(n):e[t]="";break;case C(n):e[t]=!1;break;default:try{e[t]=void 0,delete e[t]}catch(r){}}},X=null,V=null,Y=null,J=function(e){if("children"!==e){var t=V[e],n=1==m[e]?Y[e]:X[e];if(t!==n){if(O(t))return void G(Y,e,n);if(j(e))ie(Y,n,t);else if(H(e)){var r=n&&n.__html,i=t&&t.__html;null!=i&&i!==r&&(Y.innerHTML=i)}else F(Y,e,t)}}},K=function(e,t,n){if(t!==n){if(!t&&n)return void B(e,n);if(!n&&t)return void q(e,t);Y=e,X=t,V=n,_(t,n,J),Y=X=V=null}},Q=function(e,t){if(b(t)){var n=e.style;for(var r in t)w(t,r)&&(n[r]="")}},Z=function(e,t){if(b(t)){var n=e.style;for(var r in t)w(t,r)&&se(n,r,t[r])}},ee=null,te=null,ne=null,re=function(e){var t=ne[e],n=te[e];t!==n&&se(ee,e,t)},ie=function(e,t,n){t!==n&&(!n&&t?Q(e,t):n&&!t?Z(e,n):(ee=e.style,te=t,ne=n,_(t,n,re),ee=te=ne=null))},oe={},ae=["Webkit","ms","Moz","O"],ce=function(e,t){return e+t.charAt(0).toUpperCase()+t.substring(1)};R(v,function(e,t){D(ae,function(e){return oe[ce(e,t)]=!0})}),R(oe,function(e,t){v[t]=e});var le=/^-?\d+(\.\d+)?$/,se=function(e,t,n){!v[t]&&le.test(n)?e[t]=n+"px":(t="float"===t?"cssFloat":t,n=null==n||C(n)?"":n,e[t]=n)};Object.freeze||(Object.freeze=A);var ue=M,pe=null,de=function(e,t,n){var r=e.vtype,i=void 0;return r===l.TEXT?i=me(e,t,n):r===l.ELEMENT?i=ke(e,t,n):r===l.COMPONENT?i=Me(e,t,n):r===l.STATELESS_COMPONENT&&(i=Se(e,t,n)),i},fe=function(e,t,n,r,i){var o=e.vtype,a=void 0;return o===l.TEXT?a=ye(e,t,n,r,i):o===l.ELEMENT?a=be(e,t,n,r,i):o===l.COMPONENT?a=Ae(e,t,n,r,i):o===l.STATELESS_COMPONENT&&(a=Oe(e,t,n,r,i)),a},he=function(e,t){var n=e.vtype;n===l.TEXT?t=ge(e,t):n===l.ELEMENT?t=Ee(e,t):n===l.COMPONENT?t=Le(e,t):n===l.STATELESS_COMPONENT&&(t=Pe(e,t))},ve=function(e){return{vtype:l.TEXT,text:e}},me=function(e,t){var n=document.createTextNode(e.text);return Ie(t,n),n},ye=function(e,t,n){return t.text!==e.text&&n.replaceData(0,n.length,t.text),n},ge=function(e){$e(e)},xe=function(e,t){return{vtype:l.ELEMENT,type:e,props:t,refs:pe}},ke=function(e,t,n){var r=e.type,i=e.props,o=void 0;o="svg"===r||t.namespaceURI===c?document.createElementNS(c,r):document.createElement(r);var a=i.children=Te(i.children,We);if(a)for(var l=a.length,s=-1;l--;)de(a[++s],o,n);return B(o,i),Ie(t,o),He(e,o),o},be=function(e,n,r,i,o){var a=e.props,c=n.props,l=a.dangerouslySetInnerHTML&&a.dangerouslySetInnerHTML.__html,s=a.children;if(null==l&&s){var u=r.childNodes,p=c.children=Te(c.children,We);if(p)for(var d=p.length,f=-1;d--;){var h=p[++f],v=s[f];v?t(v,h,u[f],r,o):de(h,r,o)}for(var m=s.length,y=p&&p.length||0;m>y;)m-=1,he(s[m],u[m]);K(r,a,c)}else{K(r,a,c);var p=c.children=Te(c.children,We);if(p)for(var d=p.length,f=-1;d--;)de(p[++f],r,o)}return Fe(e,n,r),r},Ee=function(e,t){var n=e.props.children;if(n){var r=t.childNodes,i=$e;$e=ue;for(var o=n.length,a=-1;o--;)he(n[++a],r[a]);$e=i}je(e),$e(t)},Te=function(e,t){return S(e)?U(e,t):O(e)||C(e)?void 0:[t(e,0)]},Ce=function(e,t){return{id:I(),vtype:l.STATELESS_COMPONENT,type:e,props:t}},Se=function(e,t,n){var r=Ne(e,n),i=de(r,t,n);return i.cache=i.cache||{},i.cache[e.id]=r,i},Oe=function(n,r,i,o,a){var c=n.id,l=i.cache[c];delete i.cache[c];var s=Ne(r,a),u=t(l,s,i,o,a);return u.cache=u.cache||{},u.cache[r.id]=s,u!==i&&e(u.cache,i.cache),u},Pe=function(e,t){var n=e.id,r=t.cache[n];delete t.cache[n],he(r,t)},Ne=function(e,t){var n=e.type,r=e.props,i=Ue(t,n.contextTypes),o=n(r,i);return o&&o.render&&(o=o.render()),We(o)},we=function(e,t){return{id:I(),vtype:l.COMPONENT,type:e,props:t,refs:pe}},Me=function(e,t,n){var r=e.type,i=e.props,o=e.id,a=Ue(n,r.contextTypes),c=new r(i,a),l=c.$updater,s=c.$cache;s.parentContext=n,l.isPending=!0,c.props=c.props||i,c.componentWillMount&&(c.componentWillMount(),c.state=l.getState());var u=De(c,n),p=de(u,t,u.context);return p.cache=p.cache||{},p.cache[o]=c,s.vtree=u,s.node=p,s.isMounted=!0,Re.push(c),He(e,c),p},Ae=function(e,t,n,r,i){var o=e.id,a=n.cache[o],c=a.$updater,l=a.$cache,s=t.type,u=t.props,p=Ue(i,s.contextTypes);return delete n.cache[o],n.cache[t.id]=a,l.parentContext=i,a.componentWillReceiveProps&&(c.isPending=!0,a.componentWillReceiveProps(u,p),c.isPending=!1),c.emitUpdate(u,p),Fe(e,t,a),l.node},Le=function(e,t){var n=e.id,r=t.cache[n],i=r.$cache;delete t.cache[n],je(e),r.setState=r.forceUpdate=ue,r.componentWillUnmount&&r.componentWillUnmount(),he(i.vtree,t),delete r.setState,i.isMounted=!1,i.node=i.parentContext=i.vtree=r.refs=r.context=null},Ue=function(e,t){var n={};if(!t||!e)return n;for(var r in t)t.hasOwnProperty(r)&&(n[r]=e[r]);return n},De=function(t,n){pe=t.refs;var r=t.render();if(O(r))throw new Error("component can not render undefined");r=We(r);var i=pe=null;return t.getChildContext&&(i=t.getChildContext()),i=i?e(e({},n),i):n,r.context=i,r},Re=[],_e=function(){var e=Re,t=e.length;if(t){Re=[];for(var n=-1;t--;){var r=e[++n],i=r.$updater;r.componentDidMount&&r.componentDidMount(),i.isPending=!1,i.emitUpdate()}}},$e=function(e){e&&e.parentNode&&e.parentNode.removeChild(e)},Ie=function(e,t){T(e)?e(t):e.appendChild(t)},We=function(e){return null===e?e=xe("noscript",{}):e&&e.vtype||(e=ve(e)),e},ze=function(){return this},He=function(e,t){var n=e.ref,r=e.refs;e.vtype;r&&null!=n&&t&&(t.nodeName&&!t.getDOMNode&&(t.getDOMNode=ze),T(n)?n(t):r[n]=t)},je=function(e){var t=e.ref,n=e.refs;n&&null!=t&&(T(t)?t(null):delete n[t])},Fe=function(e,t,n){if(!e.refs)return void He(t,n);if(!t.refs)return void je(e);if(e.refs!==t.refs)return je(e),void He(t,n);var r=e.ref,i=t.ref;null==i?je(e):r!==i&&(je(e),He(t,n))},Be={updaters:[],isPending:!1,add:function(e){this.updaters.push(e)},batchUpdate:function(){if(!this.isPending){this.isPending=!0;for(var e=this.updaters,t=void 0;t=e.pop();)t.updateComponent();this.isPending=!1}}};n.prototype={emitUpdate:function(e,t){this.nextProps=e,this.nextContext=t,e||!Be.isPending?this.updateComponent():Be.add(this)},updateComponent:function(){var e=this.instance,t=this.pendingStates,n=this.nextProps,r=this.nextContext;(n||t.length>0)&&(n=n||e.props,r=r||e.context,this.nextProps=this.nextContext=null,qe(e,n,this.getState(),r,this.clearCallbacks))},addState:function(e){e&&(this.pendingStates.push(e),this.isPending||this.emitUpdate())},replaceState:function(e){var t=this.pendingStates;t.pop(),t.push([e])},getState:function(){var t=this.instance,n=this.pendingStates,r=t.state,i=t.props;return n.length&&(r=e({},r),D(n,function(n){return S(n)?void(r=e({},n[0])):(T(n)&&(n=n.call(t,r,i)),void e(r,n))}),n.length=0),r},clearCallbacks:function(){var e=this.pendingCallbacks,t=this.instance;e.length>0&&(this.pendingCallbacks=[],D(e,function(e){return e.call(t)}))},addCallback:function(e){T(e)&&this.pendingCallbacks.push(e)}},r.prototype={constructor:r,forceUpdate:function(n){var r=this.$updater,i=this.$cache,o=this.props,a=this.state,c=this.context;if(!r.isPending&&i.isMounted){var l=i.props||o,s=i.state||a,u=i.context||{},p=i.parentContext,d=i.node,f=i.vtree;i.props=i.state=i.context=null,r.isPending=!0,this.componentWillUpdate&&this.componentWillUpdate(l,s,u),this.state=s,this.props=l,this.context=u;var h=De(this,p),v=t(f,h,d,d.parentNode,h.context);v!==d&&(v.cache=v.cache||{},e(v.cache,d.cache)),i.vtree=h,i.node=v,_e(),this.componentDidUpdate&&this.componentDidUpdate(o,a,c),n&&n.call(this),r.isPending=!1,r.emitUpdate()}},setState:function(e,t){var n=this.$updater;n.addCallback(t),n.addState(e)},replaceState:function(e,t){var n=this.$updater;n.addCallback(t),n.replaceState(e)},getDOMNode:function(){var e=this.$cache.node;return e&&"NOSCRIPT"===e.tagName?null:e},isMounted:function(){return this.$cache.isMounted}};var qe=function(e,t,n,r,i){var o=!0;if(e.shouldComponentUpdate&&(o=e.shouldComponentUpdate(t,n,r)),o===!1)return e.props=t,e.state=n,void(e.context=r||{});var a=e.$cache;a.props=t,a.state=n,a.context=r||{},e.forceUpdate(i)},Ge=function(e){return e=y[e]||e,e.toLowerCase()},Xe={},Ve=function Lt(e,t,n){if(t=Ge(t),g[t]===!0)return void(e[t]=n);var r=e.eventStore||(e.eventStore={});r[t]=n,Xe[t]||(document.addEventListener(t.substr(2),Je),Xe[t]=!0),"onchange"===t&&Lt(e,"oninput",n)},Ye=function(e,t){if(t=Ge(t),g[t]===!0)return void(e[t]=null);var n=e.eventStore||(e.eventStore={});delete n[t],"onchange"===t&&delete n.oninput},Je=function(e){var t=e.target,n=e.type,r="on"+n,i=void 0;for(Be.isPending=!0;t;){var o=t,a=o.eventStore,c=a&&a[r];if(c){if(i||(i=Ke(e)),i.currentTarget=t,c.call(t,i),i.$cancalBubble)break;t=t.parentNode}else t=t.parentNode}Be.isPending=!1,Be.batchUpdate()},Ke=function(e){var t={},n=function(){return t.$cancalBubble=!0};t.nativeEvent=e;for(var r in e)"function"!=typeof e[r]?t[r]=e[r]:"stopPropagation"===r||"stopImmediatePropagation"===r?t[r]=n:t[r]=e[r].bind(e);return t},Qe={},Ze={},et=function Ut(e,n,r,o){if(!e.vtype)throw new Error("cannot render "+e+" to container");var a=n[u]||(n[u]=I()),c=Qe[a];if(c)return void(c===i?Qe[a]=c=[e,r,o]:(c[0]=e,c[2]=o,r&&(c[1]=c[1]?L(c[1],r):r)));Qe[a]=i,Ze[a]?t(Ze[a],e,n.firstChild,n,o):(n.innerHTML="",de(e,n,o)),Ze[a]=e;var s=Be.isPending;Be.isPending=!0,_e(!0),c=Qe[a],delete Qe[a];var p=null;return S(c)?p=Ut(c[0],n,c[1],c[2]):e.vtype===l.ELEMENT?p=n.firstChild:e.vtype===l.COMPONENT&&(p=n.firstChild.cache[e.id]),s||(Be.isPending=!1,Be.batchUpdate()),r&&r.call(p),p},tt=function(e,t,n){return et(e,t,n)},nt=function(e,t,n,r){var i=e.vtree?e.vtree.context:e.$cache.parentContext;return et(t,n,r,i)},rt=function(e){if(!e.nodeName)throw new Error("expect node");var t=e[u];return Ze[t]?(he(Ze[t],e.firstChild),delete Ze[t],!0):!1},it=function(e){if(null==e)return null;if(e.nodeName)return e;var t=e;if(t.getDOMNode&&t.$cache.isMounted)return t.getDOMNode();throw new Error("findDOMNode can not find Node")},ot=Object.freeze({render:tt,unstable_renderSubtreeIntoContainer:nt,unmountComponentAtNode:rt,findDOMNode:it}),at=function(e){return null!=e&&!!e.vtype},ct=function(t,n){for(var r=arguments.length,i=Array(r>2?r-2:0),o=2;r>o;o++)i[o-2]=arguments[o];var a=t.type,c=t.key,l=t.ref,s=e(e({key:c,ref:l},t.props),n),u=st.apply(void 0,[a,s].concat(i));return u.ref===t.ref&&(u.refs=t.refs),u},lt=function(e){var t=function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return st.apply(void 0,[e].concat(n))};return t.type=e,t},st=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;n>i;i++)r[i-2]=arguments[i];var o=void 0;switch(!0){case E(e):o=xe;break;case P(e):o=we;break;case N(e):o=Ce;break;default:throw new Error("React.createElement: unexpect type [ "+e+" ]")}var a=null,c=null;null!=t&&(void 0!==t.key&&(a=""+t.key,delete t.key),void 0!==t.ref&&(c=t.ref,delete t.ref));var l=o(e,W(t,r,e.defaultProps));return l.key=a,l.ref=c,l},ut="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",pt={};D(ut.split("|"),function(e){pt[e]=lt(e)});var dt=function Dt(){return Dt};dt.isRequired=dt;var ft={array:dt,bool:dt,func:dt,number:dt,object:dt,string:dt,any:dt,arrayOf:dt,element:dt,instanceOf:dt,node:dt,objectOf:dt,oneOf:dt,oneOfType:dt,shape:dt},ht=function(e){if(at(e))return e;throw new Error("expect only one child")},vt=function(e,t,n){return null==e?e:void(S(e)?U(e,function(e,r){t.call(n,e,r)}):t.call(n,e,0))},mt=function(e,t,n){if(null==e)return e;var r=[],i={};vt(e,function(e,o){var a={};a.child=t.call(n,e,o)||e,a.isEqual=a.child===e;var c=a.key=xt(e,o);i.hasOwnProperty(c)?i[c]+=1:i[c]=0,a.index=i[c],r.push(a)});var o=[];return D(r,function(e){var t=e.child,n=e.key,r=e.index,a=e.isEqual;if(null!=t&&!C(t)){if(!at(t)||null==n)return void o.push(t);0!==i[n]&&(n+=":"+r),a||(n=bt(t.key||"")+"/"+n),t=ct(t,{key:n}),o.push(t)}}),o},yt=function Rt(e){var Rt=0;return vt(e,function(){Rt++}),Rt},gt=function(e){return mt(e,A)||[]},xt=function(e,t){var n=void 0;return n=at(e)&&E(e.key)?".$"+e.key:"."+t.toString(36)},kt=/\/(?!\/)/g,bt=function(e){return(""+e).replace(kt,"//")},Et=Object.freeze({only:ht,forEach:vt,map:mt,count:yt,toArray:gt}),Tt=function _t(e,t){D(e,function(e){e&&(S(e.mixins)&&_t(e.mixins,t),t(e))})},Ct=function(e,t){R(t,function(t,n){if("getInitialState"===n)return void e.$getInitialStates.push(t);var r=e[n];T(r)&&T(t)?e[n]=L(r,t):e[n]=t})},St=function(t,n){b(n.propTypes)&&e(t.propTypes,n.propTypes),b(n.contextTypes)&&e(t.contextTypes,n.contextTypes),T(n.getDefaultProps)&&e(t.defaultProps,n.getDefaultProps()),b(n.statics)&&e(t,n.statics)},Ot=function(e,t){R(t,function(t,n){T(t)&&(e[n]=t.bind(e))})},Pt=function(){};Pt.prototype=r.prototype;var Nt=function(){var t=this,n={},r=this.setState;return this.setState=Pt,D(this.$getInitialStates,function(r){T(r)&&e(n,r.call(t))}),this.setState=r,n},wt=function(e){function t(n,i){r.call(this,n,i),this.constructor=t,e.autobind!==!1&&Ot(this,t.prototype),this.state=this.getInitialState()||this.state}if(!T(e.render))throw new Error("createClass: spec.render is not function");var n=e.mixins||[],i=n.concat(e);e.mixins=null,t.displayName=e.displayName,t.contextTypes={},t.propTypes={},t.defaultProps={};var o=t.prototype=new Pt;return o.$getInitialStates=[],Tt(i,function(e){Ct(o,e),St(t,e)}),o.getInitialState=Nt,e.mixins=n,t},Mt=e({version:"0.14.7",cloneElement:ct,isValidElement:at,createElement:st,createFactory:lt,Component:r,createClass:wt,Children:Et,PropTypes:ft,DOM:pt},ot);return Mt.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=ot,Mt}); \ No newline at end of file diff --git a/dist/react-lite.min.js.gz b/dist/react-lite.min.js.gz index cf03f6a..0f0c68f 100644 Binary files a/dist/react-lite.min.js.gz and b/dist/react-lite.min.js.gz differ diff --git a/src/Component.js b/src/Component.js index ae1c882..a11b67b 100644 --- a/src/Component.js +++ b/src/Component.js @@ -113,19 +113,18 @@ export default function Component(props, context) { this.context = context || {} } -let noop = _.noop Component.prototype = { constructor: Component, - getChildContext: noop, - componentWillUpdate: noop, - componentDidUpdate: noop, - componentWillReceiveProps: noop, - componentWillMount: noop, - componentDidMount: noop, - componentWillUnmount: noop, - shouldComponentUpdate(nextProps, nextState) { - return true - }, + // getChildContext: _.noop, + // componentWillUpdate: _.noop, + // componentDidUpdate: _.noop, + // componentWillReceiveProps: _.noop, + // componentWillMount: _.noop, + // componentDidMount: _.noop, + // componentWillUnmount: _.noop, + // shouldComponentUpdate(nextProps, nextState) { + // return true + // }, forceUpdate(callback) { let { $updater, $cache, props, state, context } = this if ($updater.isPending || !$cache.isMounted) { @@ -139,7 +138,9 @@ Component.prototype = { let vtree = $cache.vtree $cache.props = $cache.state = $cache.context = null $updater.isPending = true - this.componentWillUpdate(nextProps, nextState, nextContext) + if (this.componentWillUpdate) { + this.componentWillUpdate(nextProps, nextState, nextContext) + } this.state = nextState this.props = nextProps this.context = nextContext @@ -152,7 +153,9 @@ Component.prototype = { $cache.vtree = nextVtree $cache.node = newNode clearPendingComponents() - this.componentDidUpdate(props, state, context) + if (this.componentDidUpdate) { + this.componentDidUpdate(props, state, context) + } if (callback) { callback.call(this) } @@ -178,18 +181,20 @@ Component.prototype = { } } -export let updatePropsAndState = (component, props, state, context) => { - component.state = state - component.props = props - component.context = context || {} -} - -export let shouldUpdate = (component, nextProps, nextState, nextContext, callback) => { - let shouldComponentUpdate = component.shouldComponentUpdate(nextProps, nextState, nextContext) +let shouldUpdate = (component, nextProps, nextState, nextContext, callback) => { + let shouldComponentUpdate = true + if (component.shouldComponentUpdate) { + shouldComponentUpdate = component.shouldComponentUpdate(nextProps, nextState, nextContext) + } if (shouldComponentUpdate === false) { - updatePropsAndState(component, nextProps, nextState, nextContext) + component.props = nextProps + component.state = nextState + component.context = nextContext || {} return } - updatePropsAndState(component.$cache, nextProps, nextState, nextContext) + let cache = component.$cache + cache.props = nextProps + cache.state = nextState + cache.context = nextContext || {} component.forceUpdate(callback) } \ No newline at end of file diff --git a/src/createElement.js b/src/createElement.js index 37d4d7d..beb4395 100644 --- a/src/createElement.js +++ b/src/createElement.js @@ -1,5 +1,5 @@ import * as _ from './util' -import { createVelem, createVcomponent, createVstatelessComponent, handleVnodeWithRef } from './virtual-dom' +import { createVelem, createVcomponent, createVstatelessComponent } from './virtual-dom' export let isValidElement = obj => obj != null && !!obj.vtype @@ -36,7 +36,6 @@ let createElement = (type, props, ...children) => { } let key = null let ref = null - let hasRef = false if (props != null) { if (props.key !== undefined) { key = '' + props.key @@ -45,15 +44,11 @@ let createElement = (type, props, ...children) => { if (props.ref !== undefined) { ref = props.ref delete props.ref - hasRef = true } } let vnode = createVnode(type, _.mergeProps(props, children, type.defaultProps)) vnode.key = key vnode.ref = ref - if (hasRef && createVnode !== createVstatelessComponent) { - handleVnodeWithRef(vnode) - } return vnode } diff --git a/src/virtual-dom.js b/src/virtual-dom.js index f49325b..796c48e 100644 --- a/src/virtual-dom.js +++ b/src/virtual-dom.js @@ -1,9 +1,9 @@ import * as _ from './util' import { VNODE_TYPE, DIFF_TYPE, SVGNamespaceURI } from './constant' -import { isValidElement } from './createElement' import diff from './diff' let noop = _.noop +let refs = null export let initTree = (vtree, parentNode, parentContext) => { let { vtype } = vtree @@ -77,7 +77,8 @@ let destroyVtext = textNode => { export let createVelem = (type, props) => ({ vtype: VNODE_TYPE.ELEMENT, type: type, - props: props + props: props, + refs: refs }) let initVelem = (velem, parentNode, parentContext) => { @@ -163,7 +164,6 @@ let destroyVelem = (velem, node) => { removeNode(node) } - let getFlattenChildren = (children, iteratee) => { if (_.isArr(children)) { return _.flattenChildren(children, iteratee) @@ -222,7 +222,8 @@ export let createVcomponent = (type, props) => ({ id: _.getUid(), vtype: VNODE_TYPE.COMPONENT, type: type, - props: props + props: props, + refs: refs }) let initVcomponent = (vcomponent, parentNode, parentContext) => { @@ -233,8 +234,10 @@ let initVcomponent = (vcomponent, parentNode, parentContext) => { cache.parentContext = parentContext updater.isPending = true component.props = component.props || props - component.componentWillMount() - component.state = updater.getState() + if (component.componentWillMount) { + component.componentWillMount() + component.state = updater.getState() + } let vtree = renderComponent(component, parentContext) let node = initTree(vtree, parentNode, vtree.context) node.cache = node.cache || {} @@ -262,9 +265,11 @@ let updateVcomponent = (vcomponent, newVcomponent, node, parentNode, parentConte delete node.cache[id] node.cache[newVcomponent.id] = component cache.parentContext = parentContext - updater.isPending = true - component.componentWillReceiveProps(nextProps, componentContext) - updater.isPending = false + if (component.componentWillReceiveProps) { + updater.isPending = true + component.componentWillReceiveProps(nextProps, componentContext) + updater.isPending = false + } updater.emitUpdate(nextProps, componentContext) updateRef(vcomponent, newVcomponent, component) return cache.node @@ -277,19 +282,15 @@ let destroyVcomponent = (vcomponent, node) => { delete node.cache[id] detachRef(vcomponent) component.setState = component.forceUpdate = noop - component.componentWillUnmount() + if (component.componentWillUnmount) { + component.componentWillUnmount() + } destroyTree(cache.vtree, node) delete component.setState cache.isMounted = false cache.node = cache.parentContext = cache.vtree = component.refs = component.context = null } -let setRefs = noop -export let handleVnodeWithRef = vnode => { - if (setRefs !== noop) { - setRefs(vnode) - } -} export let getContextByTypes = (curContext, contextTypes) => { let context = {} if (!contextTypes || !curContext) { @@ -303,25 +304,23 @@ export let getContextByTypes = (curContext, contextTypes) => { return context } -let bindRefs = refs => vnode => { - vnode.refs = vnode.refs || refs -} - export let renderComponent = (component, parentContext) => { - setRefs = bindRefs(component.refs) + refs = component.refs let vtree = component.render() if (_.isUndefined(vtree)) { throw new Error('component can not render undefined') } vtree = getVnode(vtree) - let curContext = component.getChildContext() + let curContext = refs = null + if (component.getChildContext) { + curContext = component.getChildContext() + } if (curContext) { curContext = _.extend(_.extend({}, parentContext), curContext) } else { curContext = parentContext } vtree.context = curContext - setRefs = noop return vtree } @@ -337,7 +336,9 @@ export let clearPendingComponents = () => { while (len--) { let component = components[++i] let updater = component.$updater - component.componentDidMount() + if (component.componentDidMount) { + component.componentDidMount() + } updater.isPending = false updater.emitUpdate() } @@ -388,13 +389,12 @@ let appendNode = (parentNode, node) => { let getVnode = vnode => { if (vnode === null) { vnode = createVelem('noscript', {}) - } else if (!vnode.vtype) { + } else if (!vnode || !vnode.vtype) { vnode = createVtext(vnode) } return vnode } - let getDOMNode = function() { return this } let attachRef = (vtree, refValue) => {