Browse Source
Merge pull request #939 from ryandeba/escape-attributes
escpae quotes in Component.toHTML
pull/947/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
11 additions and
1 deletions
-
src/dom_components/model/Component.js
-
test/specs/dom_components/model/Component.js
|
|
|
@ -670,7 +670,7 @@ const Component = Backbone.Model.extend(Styleable).extend( |
|
|
|
const attributes = this.getAttrToHTML(); |
|
|
|
|
|
|
|
for (let attr in attributes) { |
|
|
|
const value = attributes[attr]; |
|
|
|
const value = attributes[attr].replace(/"/g, '"'); |
|
|
|
|
|
|
|
if (!isUndefined(value)) { |
|
|
|
attrs.push(`${attr}="${value}"`); |
|
|
|
|
|
|
|
@ -135,6 +135,16 @@ module.exports = { |
|
|
|
expect(obj.toHTML()).toEqual('<div/>'); |
|
|
|
}); |
|
|
|
|
|
|
|
it('Component toHTML with quotes in attribute', () => { |
|
|
|
obj = new Component(); |
|
|
|
let attrs = obj.get('attributes'); |
|
|
|
attrs['data-test'] = '"value"'; |
|
|
|
obj.set('attributes', attrs); |
|
|
|
expect(obj.toHTML()).toEqual( |
|
|
|
'<div data-test=""value""></div>' |
|
|
|
); |
|
|
|
}); |
|
|
|
|
|
|
|
it('Component parse empty div', () => { |
|
|
|
var el = document.createElement('div'); |
|
|
|
obj = Component.isComponent(el); |
|
|
|
|