@cicada/render
Advanced tools
Comparing version 1.0.0-alpha12 to 1.0.0-alpha13
@@ -11,2 +11,6 @@ 'use strict'; | ||
var _typeof2 = require('babel-runtime/helpers/typeof'); | ||
var _typeof3 = _interopRequireDefault(_typeof2); | ||
var _extends2 = require('babel-runtime/helpers/extends'); | ||
@@ -16,6 +20,2 @@ | ||
var _typeof2 = require('babel-runtime/helpers/typeof'); | ||
var _typeof3 = _interopRequireDefault(_typeof2); | ||
exports.default = convertFragment; | ||
@@ -69,15 +69,2 @@ | ||
function strictType(a) { | ||
return (typeof a === 'undefined' ? 'undefined' : (0, _typeof3.default)(a)) !== 'object' ? typeof a === 'undefined' ? 'undefined' : (0, _typeof3.default)(a) : Array.isArray(a) ? 'array' : 'object'; | ||
} | ||
function partialDeepEqual(a, b) { | ||
if (strictType(a) !== strictType(b)) return false; | ||
if (!(0, _util.isObject)(a)) return a === b; | ||
return (0, _util.every)(a, function (v, k) { | ||
return partialDeepEqual(v, b[k]); | ||
}); | ||
} | ||
function computeFrom(linkState, utilInstances) { | ||
@@ -92,9 +79,7 @@ return (0, _util.mapValues)(linkState, function (_ref) { | ||
function computeTo(linkState, state, utilInstances) { | ||
var recomputed = {}; | ||
(0, _util.each)(linkState, function (_ref2, name) { | ||
var to = _ref2.to; | ||
recomputed = (0, _extends3.default)({}, to((0, _extends3.default)({ value: state[name], state: state }, utilInstances))); | ||
to((0, _extends3.default)({ value: state[name], state: state }, utilInstances)); | ||
}); | ||
return recomputed; | ||
} | ||
@@ -224,9 +209,3 @@ | ||
// CAUTION 注意,这里只针对外部引起的变化进行来重新内部render | ||
var stateTree = instance.stateTree; | ||
var newInner = computeTo(linkState, state, instance.background.instances); | ||
(0, _util.each)(newInner, function (newState, statePath) { | ||
if (!partialDeepEqual(newState, stateTree.get(statePath))) { | ||
stateTree.merge(statePath, newState, { type: _constant.REASON_COMPONENT_RECEIVE_STATE }); | ||
} | ||
}); | ||
computeTo(linkState, state, instance.background.instances); | ||
}; | ||
@@ -233,0 +212,0 @@ |
{ | ||
"name": "@cicada/render", | ||
"version": "1.0.0-alpha12", | ||
"version": "1.0.0-alpha13", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
309680
7528