diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index 7b9c867c6..1f0cf7b8a 100644 --- a/src/dom_components/model/Component.js +++ b/src/dom_components/model/Component.js @@ -1371,10 +1371,9 @@ export default class Component extends Model.extend(Styleable) { * Return HTML string of the component * @param {Object} [opts={}] Options * @param {String} [opts.tag] Custom tagName - * @param {Object|Function} [opts.attributes=null] You can pass an object of custom attributes to replace. + * @param {Object|Function} [opts.attributes=null] You can pass an object of custom attributes to replace with the current ones or you can even pass a function to generate attributes dynamically. * @param {Boolean} [opts.withProps] Include component properties as `data-gjs-*` attributes. This allows you to have re-importable HTML. - * @param {Boolean} [opts.beautifyAttr] In case the attribute value contains a `"` char, instead of escaping it (`attr="value ""`), the attribute will be quoted using single quotes (`attr='value "'`). - * with the current one or you can even pass a function to generate attributes dynamically + * @param {Boolean} [opts.altQuoteAttr] In case the attribute value contains a `"` char, instead of escaping it (`attr="value ""`), the attribute will be quoted using single quotes (`attr='value "'`). * @return {String} HTML string * @example * // Simple HTML return @@ -1436,7 +1435,7 @@ export default class Component extends Model.extend(Styleable) { val && attrs.push(attr); } else { let valueRes = ''; - if (opts.beautifyAttr && isString(val) && val.indexOf('"') >= 0) { + if (opts.altQuoteAttr && isString(val) && val.indexOf('"') >= 0) { valueRes = `'${val.replace(/'/g, ''')}'`; } else { const value = isString(val) ? val.replace(/"/g, '"') : val; diff --git a/test/specs/dom_components/model/Component.js b/test/specs/dom_components/model/Component.js index b84279cd7..71cfaf4f1 100644 --- a/test/specs/dom_components/model/Component.js +++ b/test/specs/dom_components/model/Component.js @@ -167,7 +167,7 @@ describe('Component', () => { resArr = '[1,"string",true]'; resObj = '{"a":1,"b":"string","c":true}'; res = `
`; - expect(obj.toHTML({ withProps: true, beautifyAttr: true })).toEqual(res); + expect(obj.toHTML({ withProps: true, altQuoteAttr: true })).toEqual(res); }); test('Manage correctly boolean attributes', () => {