@cicada/render
Advanced tools
Comparing version 1.1.14 to 1.1.15
@@ -500,3 +500,2 @@ 'use strict'; | ||
console.log('from...'); | ||
return stateTree.get('button.visible'); | ||
@@ -503,0 +502,0 @@ }, |
@@ -195,2 +195,32 @@ 'use strict'; | ||
test('initStyle', function () { | ||
var runInFunc = false; | ||
var container = (0, _enzyme.mount)(_react2.default.createElement(_Render2.default, { | ||
stateTree: stateTree, | ||
appearance: appearance, | ||
components: { Demo: (0, _connect2.default)(DemoComponent, 'Demo') }, | ||
background: (0, _createBackground2.default)({ | ||
jobs: { | ||
style: styleJob | ||
}, | ||
utilities: { | ||
stateTree: stateTreeUtility | ||
} | ||
}, stateTree, appearance), | ||
config: { | ||
children: [{ | ||
bind: 'demo', | ||
type: 'Demo', | ||
initStyle: 'color: red;', | ||
style: function style() { | ||
// 第一次不会被执行 | ||
runInFunc = true; | ||
} | ||
}] | ||
} | ||
})); | ||
expect(runInFunc).toEqual(false); | ||
expect(container.html()).toEqual('<div><div data-cicada-css-wq229y=""></div></div>'); | ||
}); | ||
test('fragment with style', function () { | ||
@@ -197,0 +227,0 @@ var config = { |
@@ -42,2 +42,3 @@ 'use strict'; | ||
var style = _ref.style, | ||
initStyle = _ref.initStyle, | ||
getStatePath = _ref.getStatePath; | ||
@@ -47,2 +48,4 @@ | ||
getStatePath: getStatePath, | ||
initStyle: initStyle, | ||
firstRun: true, | ||
fn: typeof style === 'function' ? style : function () { | ||
@@ -60,2 +63,7 @@ return style; | ||
function run(stateId) { | ||
// 返回初始化的style,这个方法用于style为模版函数时候需要保证样式在第一时间出现 | ||
if (stateIdToStyleFns[stateId].firstRun && stateIdToStyleFns[stateId].initStyle !== undefined) { | ||
stateIdToStyleFns[stateId].firstRun = false; | ||
return stateIdToStyleFns[stateId].initStyle; | ||
} | ||
var statePath = new _common.StatePath(stateIdToStyleFns[stateId].getStatePath()); | ||
@@ -79,5 +87,6 @@ return stateIdToStyleFns[stateId].fn((0, _extends3.default)({}, utilInstances, { statePath: statePath })); | ||
function shouldRunInRegister(stateId, _ref2) { | ||
var style = _ref2.style; | ||
var style = _ref2.style, | ||
initStyle = _ref2.initStyle; | ||
return typeof style === 'string' || (typeof style === 'undefined' ? 'undefined' : (0, _typeof3.default)(style)) === 'object'; | ||
return typeof initStyle === 'string' || typeof style === 'string' || (typeof style === 'undefined' ? 'undefined' : (0, _typeof3.default)(style)) === 'object'; | ||
} | ||
@@ -84,0 +93,0 @@ |
@@ -81,16 +81,5 @@ 'use strict'; | ||
// CAUTION 业务中大部分用的是merge的场景, 所以set这个方法默认采用merge, 同时额外提供一个mergeInitState | ||
merge: function merge() { | ||
for (var _len2 = arguments.length, arg = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
arg[_key2] = arguments[_key2]; | ||
} | ||
return stateTree.mergeStupid.apply(stateTree, arg.concat([{ type: _constant.REASON_CUSTOM_LISTENER }])); | ||
set: function set(path, value, setHard) { | ||
return stateTree[setHard ? 'mergeStupid' : 'merge'](path, value, { type: _constant.REASON_CUSTOM_LISTENER }); | ||
}, | ||
set: function set() { | ||
for (var _len3 = arguments.length, arg = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
arg[_key3] = arguments[_key3]; | ||
} | ||
return stateTree.merge.apply(stateTree, arg.concat([{ type: _constant.REASON_CUSTOM_LISTENER }])); | ||
}, | ||
test: test | ||
@@ -97,0 +86,0 @@ }; |
{ | ||
"name": "@cicada/render", | ||
"version": "1.1.14", | ||
"version": "1.1.15", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
394130
71
9593