Browse Source
Merge pull request #1040 from dsgh/support-no-name-traits Fixes #1039
Support no-name traits
pull/1045/head
Artur Arseniev
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
18 additions and
2 deletions
-
src/dom_components/model/Component.js
-
test/specs/dom_components/model/Component.js
|
|
|
@ -514,9 +514,10 @@ const Component = Backbone.Model.extend(Styleable).extend( |
|
|
|
traits.each(trait => { |
|
|
|
found = 1; |
|
|
|
if (!trait.get('changeProp')) { |
|
|
|
const name = trait.get('name'); |
|
|
|
const value = trait.getInitValue(); |
|
|
|
if (value) { |
|
|
|
attrs[trait.get('name')] = value; |
|
|
|
if (name && value) { |
|
|
|
attrs[name] = value; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
@ -67,6 +67,21 @@ module.exports = { |
|
|
|
expect(obj.get('stylable')).toEqual(true); |
|
|
|
}); |
|
|
|
|
|
|
|
it('Sets attributes correctly from traits', () => { |
|
|
|
obj.set('traits', [ |
|
|
|
{ |
|
|
|
label: 'Title', |
|
|
|
name: 'title', |
|
|
|
value: 'The title' |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: 'Context', |
|
|
|
value: 'primary' |
|
|
|
} |
|
|
|
]); |
|
|
|
expect(obj.get('attributes')).toEqual({ title: 'The title' }); |
|
|
|
}); |
|
|
|
|
|
|
|
it('Has expected name', () => { |
|
|
|
expect(obj.getName()).toEqual('Box'); |
|
|
|
}); |
|
|
|
|