Browse Source

Update getStyle

pull/3901/head
Artur Arseniev 5 years ago
parent
commit
5afcf62189
  1. 8
      src/dom_components/model/Component.js
  2. 5
      src/domain_abstract/model/Styleable.js

8
src/dom_components/model/Component.js

@ -476,8 +476,10 @@ export default class Component extends Model.extend(Styleable) {
* Get the style of the component
* @return {Object}
*/
getStyle(opts = {}) {
getStyle(options = {}, optsAdd = {}) {
const em = this.em;
const prop = isString(options) ? options : '';
const opts = prop ? optsAdd : options;
if (em && em.getConfig('avoidInlineStyle') && !opts.inline) {
const state = em.get('state');
@ -486,11 +488,11 @@ export default class Component extends Model.extend(Styleable) {
this.rule = rule;
if (rule) {
return rule.getStyle();
return rule.getStyle(prop);
}
}
return Styleable.getStyle.call(this);
return Styleable.getStyle.call(this, prop);
}
/**

5
src/domain_abstract/model/Styleable.js

@ -21,9 +21,10 @@ export default {
* Get style object
* @return {Object}
*/
getStyle() {
getStyle(prop) {
const style = this.get('style') || {};
return { ...style };
const result = { ...style };
return prop && isString(prop) ? result[prop] : result;
},
/**

Loading…
Cancel
Save