Browse Source

Prevent error on getAttributes when classes collection doesn't exist

15-beta
Artur Arseniev 8 years ago
parent
commit
b76760d4cc
  1. 2
      src/css_composer/index.js
  2. 10
      src/dom_components/model/Component.js

2
src/css_composer/index.js

@ -201,7 +201,7 @@ module.exports = () => {
var rule = this.get(selectors, s, w, opt);
// do not create rules that were found before
// unless this is an at-rule, for which multiple declarations
// unless this is a single at-rule, for which multiple declarations
// make sense (e.g. multiple `@font-type`s)
if (rule && rule.config && !rule.config.singleAtRule) {
return rule;

10
src/dom_components/model/Component.js

@ -153,13 +153,13 @@ const Component = Backbone.Model.extend(Styleable).extend(
this.config = opt.config || {};
this.ccid = Component.createId(this);
this.set('attributes', this.get('attributes') || {});
this.listenTo(this, 'change:script', this.scriptUpdated);
this.listenTo(this, 'change:tagName', this.tagUpdated);
this.listenTo(this, 'change:attributes', this.attrUpdated);
this.initClasses();
this.initTraits();
this.initComponents();
this.initToolbar();
this.listenTo(this, 'change:script', this.scriptUpdated);
this.listenTo(this, 'change:tagName', this.tagUpdated);
this.listenTo(this, 'change:attributes', this.attrUpdated);
this.set('status', '');
// Register global updates for collection properties
@ -356,7 +356,9 @@ const Component = Backbone.Model.extend(Styleable).extend(
const id = this.getId();
// Add classes
this.get('classes').each(cls => classes.push(cls.get('name')));
this.get('classes').forEach(cls =>
classes.push(isString(cls) ? cls : cls.get('name'))
);
classes.length && (attributes.class = classes.join(' '));
// Check if we need an ID on the component

Loading…
Cancel
Save