From fccf521d1b59d3d8bd547dd6d32ab9bfd5305c44 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 17 Dec 2021 18:01:20 +0100 Subject: [PATCH] Fix __setProperties --- src/style_manager/model/PropertyComposite.js | 2 +- test/specs/style_manager/model/Properties.js | 39 ++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/style_manager/model/PropertyComposite.js b/src/style_manager/model/PropertyComposite.js index 6cf271056..450dfd23b 100644 --- a/src/style_manager/model/PropertyComposite.js +++ b/src/style_manager/model/PropertyComposite.js @@ -164,7 +164,7 @@ export default Property.extend({ __setProperties(values = {}, opts = {}) { this.getProperties().forEach(prop => { const value = values[prop.getId()]; - !isUndefined(value) && prop.__getFullValue() !== value && prop.upValue(value, opts); + prop.__getFullValue() !== value && prop.upValue(value, opts); }); }, diff --git a/test/specs/style_manager/model/Properties.js b/test/specs/style_manager/model/Properties.js index bd31414bf..2ed69d873 100644 --- a/test/specs/style_manager/model/Properties.js +++ b/test/specs/style_manager/model/Properties.js @@ -231,6 +231,45 @@ describe('StyleManager properties logic', () => { }); }); + test('Parent styles are ignored if on the lower device', () => { + const rule2 = cssc.addRules(` + @media (max-width: 992px) { + .cls { + padding: 11px 22px; + padding-left: 44px; + } + } + `)[0]; + dv.select('tablet'); + obj.__upSel(); + expect(obj.getLastSelected()).toBe(rule2); + expect(compTypeProp.hasValue({ noParent: true })).toBe(true); + [ + [propATest, '11px'], + [propBTest, '22px'], + [propCTest, '11px'], + [propDTest, '44px'], + ].forEach(item => { + const prop = compTypeProp.getProperty(item[0]); + expect(prop.getFullValue()).toBe(item[1]); + }); + + dv.select('desktop'); + obj.__upSel(); + expect(obj.getLastSelected()).toBe(rule1); + expect(obj.getSelectedParents()).toEqual([]); + [ + [propATest, ''], + [propBTest, ''], + [propCTest, ''], + [propDTest, ''], + ].forEach(item => { + const prop = compTypeProp.getProperty(item[0]); + expect(prop.hasValue()).toBe(false); + expect(prop.getFullValue()).toBe(item[1]); + }); + }); + test('getStyleFromProps with custom toStyle', () => { rule1.setStyle({ padding: '1px 2px 3px 4px' }); obj.__upSel();