Browse Source

Search alternative style target for not detached props

pull/2620/head
Artur Arseniev 7 years ago
parent
commit
198298d005
  1. 33
      src/style_manager/view/PropertyStackView.js

33
src/style_manager/view/PropertyStackView.js

@ -105,6 +105,16 @@ export default PropertyCompositeView.extend({
return this.getLayers().getFullValue(); return this.getLayers().getFullValue();
}, },
_getClassRule() {
const { em } = this;
const selected = em.getSelected();
const targetAlt = em.get('StyleManager').getModelToStyle(selected, {
skipAdd: 1,
useClasses: 1
});
return targetAlt !== selected && targetAlt;
},
/** /**
* Refresh layers * Refresh layers
* */ * */
@ -113,31 +123,34 @@ export default PropertyCompositeView.extend({
const { model, em } = this; const { model, em } = this;
const layers = this.getLayers(); const layers = this.getLayers();
const detached = model.get('detached'); const detached = model.get('detached');
const property = model.get('property');
const target = this.getTarget(); const target = this.getTarget();
let style, valueComput, targetAlt; const valueComput = this.getComputedValue();
const selected = em.getSelected();
let style, targetAlt;
// With detached layers values will be assigned to their properties // With detached layers values will be assigned to their properties
if (detached) { if (detached) {
const selected = em.getSelected();
style = target ? target.getStyle() : 0; style = target ? target.getStyle() : 0;
valueComput = this.getComputedValue();
// If the style object is empty but the target has a computed value, // If the style object is empty but the target has a computed value,
// that means the style might exist in some other place // that means the style might exist in some other place
if ((!style || !keys(style).length) && valueComput && selected) { if ((!style || !keys(style).length) && valueComput && selected) {
// The target is a component but the style is in class rules // The target is a component but the style is in the class rules
targetAlt = em.get('StyleManager').getModelToStyle(selected, { targetAlt = this._getClassRule();
skipAdd: 1, style = targetAlt ? targetAlt.getStyle() : 0;
useClasses: 1
});
style = targetAlt !== selected ? targetAlt.getStyle() : 0;
} }
layersObj = layers.getLayersFromStyle(style || {}); layersObj = layers.getLayersFromStyle(style || {});
} else { } else {
let value = this.getTargetValue({ ignoreDefault: 1 }); let value = this.getTargetValue({ ignoreDefault: 1 });
if (!value) value = this.getComputedValue(); if (!value && valueComput) {
// Computed value is not always reliable due to the browser's CSSOM parser
// so, at first, try to check the alternative target style
targetAlt = this._getClassRule();
value = targetAlt ? targetAlt.getStyle()[property] : valueComput;
}
value = value == model.getDefaultValue() ? '' : value; value = value == model.getDefaultValue() ? '' : value;
layersObj = layers.getLayersFromValue(value); layersObj = layers.getLayersFromValue(value);

Loading…
Cancel
Save