Browse Source

Don't update main prop on change of composite

up-style-manager
Artur Arseniev 5 years ago
parent
commit
5110a0c4c6
  1. 3
      src/style_manager/index.js
  2. 15
      test/specs/style_manager/model/Properties.js

3
src/style_manager/index.js

@ -586,6 +586,7 @@ export default () => {
const isStack = prop.getType() === 'stack';
const isComposite = prop.getType() === 'composite';
const opt = { ...opts, __up: true };
const canUpdate = !isComposite;
let newLayers = isStack ? prop.__getLayersFromStyle(style) : [];
let newProps = isComposite ? prop.__getPropsFromStyle(style) : {};
let newValue = hasVal ? value : null;
@ -616,7 +617,7 @@ export default () => {
}
prop.__setParentTarget(parentTarget);
prop.__getFullValue() !== newValue && prop.upValue(newValue, opt);
canUpdate && prop.__getFullValue() !== newValue && prop.upValue(newValue, opt);
isStack && prop.__setLayers(newLayers || []);
if (isComposite) {
const props = prop.getProperties();

15
test/specs/style_manager/model/Properties.js

@ -395,6 +395,21 @@ describe('StyleManager properties logic', () => {
});
});
test('Update on the rule reflects to the property correctly', () => {
rule1.setStyle({ padding: '1px 2px 3px 4px' });
obj.__upSel();
compTypeProp.getProperty(propCTest).upValue('50%');
[
[propATest, '1px'],
[propBTest, '2px'],
[propCTest, '50%'],
[propDTest, '4px'],
].forEach(item => {
const prop = compTypeProp.getProperty(item[0]);
expect(prop.getFullValue()).toBe(item[1]);
});
});
test('Update on properties reflects to the rule correctly', () => {
compTypeProp.set('detached', false);
rule1.setStyle({ padding: '1px 2px 3px 4px' });

Loading…
Cancel
Save