From 40cb1663f73db92eba1489de839994001874ed3b Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Tue, 30 Nov 2021 12:31:21 +0100 Subject: [PATCH] Move update property logic --- src/style_manager/index.js | 40 +++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/style_manager/index.js b/src/style_manager/index.js index 35778296c..8eb7c4e94 100644 --- a/src/style_manager/index.js +++ b/src/style_manager/index.js @@ -566,28 +566,32 @@ export default () => { sectors.map(sector => { sector.getProperties().map(prop => { - const name = prop.getName(); - const value = style[name]; - const hasVal = propDef(value); - let newValue = hasVal ? value : null; - let parentTarget = null; - - if (!hasVal) { - newValue = null; - const parentItem = parentStyles.filter(p => propDef(p.style[name]))[0]; - - if (parentItem) { - newValue = parentItem.style[name]; - parentTarget = parentItem.target; - } - } - - prop.__setParentTarget(parentTarget); - prop.__getFullValue() !== newValue && prop.upValue(newValue, { ...opts, __up: true }); + this.__upProp(prop, style, parentStyles, opts); }); }); }, + __upProp(prop, style, parentStyles, opts) { + const name = prop.getName(); + const value = style[name]; + const hasVal = propDef(value); + let newValue = hasVal ? value : null; + let parentTarget = null; + + if (!hasVal) { + newValue = null; + const parentItem = parentStyles.filter(p => propDef(p.style[name]))[0]; + + if (parentItem) { + newValue = parentItem.style[name]; + parentTarget = parentItem.target; + } + } + + prop.__setParentTarget(parentTarget); + prop.__getFullValue() !== newValue && prop.upValue(newValue, { ...opts, __up: true }); + }, + destroy() { [properties, sectors].forEach(coll => { coll.reset();