@cicada/render
Advanced tools
Comparing version 1.1.16 to 1.1.17
@@ -97,3 +97,3 @@ 'use strict'; | ||
})); | ||
expect(container.html()).toEqual('<div data-cicada-cls1="" data-cicada-cls2=""></div>'); | ||
expect(container.html()).toEqual('<div data-cicada-cls-cls1="" data-cicada-cls-cls2=""></div>'); | ||
}); | ||
@@ -132,5 +132,5 @@ | ||
stateTree.set('demo.value', 'cls1 cls2 hide'); | ||
expect(container.html()).toEqual('<div><div>cls1 cls2 hide</div><div data-cicada-cls1="" data-cicada-cls2="" data-cicada-hide=""></div></div>'); | ||
expect(container.html()).toEqual('<div><div>cls1 cls2 hide</div><div data-cicada-cls-cls1="" data-cicada-cls-cls2="" data-cicada-cls-hide=""></div></div>'); | ||
stateTree.set('demo.value', 'cls1 show'); | ||
expect(container.html()).toEqual('<div><div>cls1 show</div><div data-cicada-cls1="" data-cicada-show=""></div></div>'); | ||
expect(container.html()).toEqual('<div><div>cls1 show</div><div data-cicada-cls-cls1="" data-cicada-cls-show=""></div></div>'); | ||
}); |
@@ -116,5 +116,5 @@ 'use strict'; | ||
})); | ||
expect(container.html()).toEqual('<div data-cicada-css-1w23buh="" data-cicada-abc="">content: </div>'); | ||
expect(container.html()).toEqual('<div data-cicada-css-1w23buh="" data-cicada-cls-abc="">content: </div>'); | ||
container.instance().background.instances.business.set('content', 'updated'); | ||
expect(container.html()).toEqual('<div data-cicada-css-1w23buh="" data-cicada-abc="">content: updated</div>'); | ||
expect(container.html()).toEqual('<div data-cicada-css-1w23buh="" data-cicada-cls-abc="">content: updated</div>'); | ||
}); | ||
@@ -121,0 +121,0 @@ |
@@ -158,3 +158,3 @@ 'use strict'; | ||
test('style as function and replace', function () { | ||
test('style as function and changed', function () { | ||
var container = _react2.default.createElement(_Render2.default, { | ||
@@ -194,2 +194,4 @@ stateTree: stateTree, | ||
expect(node.innerHTML).toEqual('<div><div>background-color: #eee</div><div data-cicada-css-607pib=""></div></div>'); | ||
stateTree.set('demo.value', 'background-color: red'); | ||
expect(node.innerHTML).toEqual('<div><div>background-color: red</div><div data-cicada-css-17ikwar=""></div></div>'); | ||
}); | ||
@@ -196,0 +198,0 @@ |
@@ -15,8 +15,10 @@ 'use strict'; | ||
var _Scope = require('../components/Scope'); | ||
var _testUtils = require('./testUtils'); | ||
var _Scope2 = _interopRequireDefault(_Scope); | ||
var _Repeat = require('./components/Repeat'); | ||
var _testUtils = require('./testUtils'); | ||
var Repeat = _interopRequireWildcard(_Repeat); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -27,30 +29,2 @@ | ||
var stateTree = void 0; | ||
var Repeat = { | ||
getDefaultState: function getDefaultState() { | ||
return { | ||
items: [] | ||
}; | ||
}, | ||
stateTypes: { | ||
items: _propTypes2.default.array | ||
}, | ||
render: function render(_ref) { | ||
var state = _ref.state, | ||
children = _ref.children; | ||
return _react2.default.createElement( | ||
'div', | ||
{ className: 'repeat-wrapper' }, | ||
state.items.map(function (item, index) { | ||
return _react2.default.createElement( | ||
_Scope2.default, | ||
{ relativeChildStatePath: 'items.' + index, key: item.key }, | ||
_react.Children.map(children, function (child) { | ||
return _react2.default.cloneElement(child); | ||
}) | ||
); | ||
}) | ||
); | ||
} | ||
}; | ||
var Input = { | ||
@@ -65,4 +39,4 @@ getDefaultState: function getDefaultState() { | ||
}, | ||
render: function render(_ref2) { | ||
var state = _ref2.state; | ||
render: function render(_ref) { | ||
var state = _ref.state; | ||
@@ -80,10 +54,10 @@ return _react2.default.createElement( | ||
name: { | ||
from: function from(_ref3) { | ||
var stateTree = _ref3.stateTree; | ||
from: function from(_ref2) { | ||
var stateTree = _ref2.stateTree; | ||
return stateTree.get('first.value', '') + '-' + stateTree.get('second.value', ''); | ||
}, | ||
to: function to(_ref4) { | ||
var value = _ref4.value, | ||
stateTree = _ref4.stateTree; | ||
to: function to(_ref3) { | ||
var value = _ref3.value, | ||
stateTree = _ref3.stateTree; | ||
@@ -90,0 +64,0 @@ var _value$split = value.split('-'), |
@@ -57,2 +57,10 @@ 'use strict'; | ||
var _style = require('../background/job/style'); | ||
var styleJob = _interopRequireWildcard(_style); | ||
var _className = require('../background/job/className'); | ||
var classNameJob = _interopRequireWildcard(_className); | ||
var _convertFragment = require('../convertFragment'); | ||
@@ -87,3 +95,5 @@ | ||
jobs: { | ||
visible: visibilityJob | ||
visible: visibilityJob, | ||
style: styleJob, | ||
className: classNameJob | ||
}, | ||
@@ -90,0 +100,0 @@ utilities: { |
@@ -46,7 +46,8 @@ 'use strict'; | ||
return s; | ||
}).map(function (c) { | ||
return 'cls-' + c; | ||
}); | ||
var oldStyleList = appearance.getStyleById(stateId); | ||
appearance.replaceStyleById(stateId, oldStyleList.filter(function (cls) { | ||
return (/^css-/.test(cls) | ||
); | ||
return !/^cls-/.test(cls); | ||
}).concat(classNames)); | ||
@@ -53,0 +54,0 @@ } |
@@ -79,3 +79,6 @@ 'use strict'; | ||
var rule = appearance.insertCSSRuleById(result); | ||
appearance.addStyleById(stateId, rule); | ||
var oldStyleList = appearance.getStyleById(stateId); | ||
appearance.replaceStyleById(stateId, oldStyleList.filter(function (cls) { | ||
return !/^css-/.test(cls); | ||
}).concat(rule)); | ||
} | ||
@@ -82,0 +85,0 @@ } |
{ | ||
"name": "@cicada/render", | ||
"version": "1.1.16", | ||
"version": "1.1.17", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
399392
71
9698