diff --git a/src/style_manager/index.js b/src/style_manager/index.js index df9dfdd52..233e37dc8 100644 --- a/src/style_manager/index.js +++ b/src/style_manager/index.js @@ -617,7 +617,10 @@ export default () => { prop.__setParentTarget(parentTarget); prop.__getFullValue() !== newValue && prop.upValue(newValue, { ...opts, __up: true }); isStack && prop.__setLayers(newLayers || []); - isComposite && prop.__setProperties(newProps || {}); + if (isComposite) { + prop.__setProperties(newProps || {}); + prop.getProperties().map(pr => pr.__setParentTarget(parentTarget)); + } }, destroy() { diff --git a/src/style_manager/model/PropertyStack.js b/src/style_manager/model/PropertyStack.js index 803af5944..a12397492 100644 --- a/src/style_manager/model/PropertyStack.js +++ b/src/style_manager/model/PropertyStack.js @@ -163,10 +163,6 @@ export default Property.extend({ return isArray(result) ? result : [result]; }, - hasValue(opts) { - return PropertyBase.prototype.hasValue.call(this, opts); - }, - /** * Add new layer to the stack * @param {Object} [props={}] Layer props diff --git a/test/specs/style_manager/model/Properties.js b/test/specs/style_manager/model/Properties.js index 0d643adbe..bd31414bf 100644 --- a/test/specs/style_manager/model/Properties.js +++ b/test/specs/style_manager/model/Properties.js @@ -184,6 +184,53 @@ describe('StyleManager properties logic', () => { }); }); + test('On clear removes all values', () => { + rule1.setStyle({ padding: '1px 2px 3px 4px' }); + obj.__upSel(); + expect(compTypeProp.hasValue()).toBe(true); + + compTypeProp.clear(); + expect(compTypeProp.hasValue()).toBe(false); + expect(rule1.getStyle()).toEqual({ + __p: false, + [propTest]: '', + [propATest]: '', + [propBTest]: '', + [propCTest]: '', + [propDTest]: '', + }); + }); + + test('Get the values from parent style', () => { + rule1.setStyle({ + padding: '11px 22px', + 'padding-left': '44px', + }); + const rule2 = cssc.addRules(` + @media (max-width: 992px) { + .cls { color: red; } + } + `)[0]; + dv.select('tablet'); + obj.__upSel(); + expect(obj.getLastSelected()).toBe(rule2); + expect(obj.getSelectedParents()).toEqual([rule1]); + + expect(compTypeProp.hasValue()).toBe(true); + expect(compTypeProp.hasValue({ noParent: true })).toBe(false); + [ + [propATest, '11px'], + [propBTest, '22px'], + [propCTest, '11px'], + [propDTest, '44px'], + ].forEach(item => { + const prop = compTypeProp.getProperty(item[0]); + expect(prop.hasValue()).toBe(true); + expect(prop.hasValue({ noParent: true })).toBe(false); + expect(prop.getFullValue()).toBe(item[1]); + }); + }); + test('getStyleFromProps with custom toStyle', () => { rule1.setStyle({ padding: '1px 2px 3px 4px' }); obj.__upSel();