Browse Source

Skip the CSSRule from the JSON if there is no `style`

symbols-2
Artur Arseniev 5 years ago
parent
commit
d68d428201
  1. 11
      src/css_composer/model/CssRules.js

11
src/css_composer/model/CssRules.js

@ -1,7 +1,9 @@
import Backbone from 'backbone';
import CssRule from './CssRule';
export default Backbone.Collection.extend({
const { Collection } = Backbone;
export default Collection.extend({
model: CssRule,
initialize(models, opt) {
@ -15,6 +17,11 @@ export default Backbone.Collection.extend({
});
},
toJSON(opts) {
const result = Collection.prototype.toJSON.call(this, opts);
return result.filter(i => i.style);
},
onAdd(model) {
model.ensureSelectors(); // required for undo
},
@ -30,6 +37,6 @@ export default Backbone.Collection.extend({
models = this.editor.get('Parser').parseCss(models);
}
opt.em = this.editor;
return Backbone.Collection.prototype.add.apply(this, [models, opt]);
return Collection.prototype.add.apply(this, [models, opt]);
}
});

Loading…
Cancel
Save