Browse Source
Merge pull request #550 from ryandeba/attributes-without-values
Include value-less attributes in component.toHTML()
pull/561/head
Artur Arseniev
9 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
11 additions and
1 deletions
-
src/dom_components/model/Component.js
-
test/specs/dom_components/model/Component.js
|
|
|
@ -554,7 +554,7 @@ module.exports = Backbone.Model.extend(Styleable).extend({ |
|
|
|
for (let attr in attributes) { |
|
|
|
const value = attributes[attr]; |
|
|
|
|
|
|
|
if (!isUndefined(value) && value !== '') { |
|
|
|
if (!isUndefined(value)) { |
|
|
|
attrs.push(`${attr}="${value}"`); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -82,6 +82,16 @@ module.exports = { |
|
|
|
expect(obj.toHTML()).toEqual('<article data-test1="value1" data-test2="value2"></article>'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('Component toHTML with value-less attribute', () => { |
|
|
|
obj = new Component({ |
|
|
|
tagName: 'div', |
|
|
|
attributes: { |
|
|
|
'data-is-a-test': '' |
|
|
|
} |
|
|
|
}); |
|
|
|
expect(obj.toHTML()).toEqual('<div data-is-a-test=""></div>'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('Component toHTML with classes', () => { |
|
|
|
obj = new Component({ |
|
|
|
tagName: 'article' |
|
|
|
|