From d406685708a018ec733f84cd7974af6ca7543fe7 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sat, 9 Mar 2024 12:46:03 +0400 Subject: [PATCH] Fix boolean values when getting HTML with withProp --- src/dom_components/model/Component.ts | 3 ++- test/specs/dom_components/model/Component.ts | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dom_components/model/Component.ts b/src/dom_components/model/Component.ts index 04de8ca6f7..ca9861334d 100644 --- a/src/dom_components/model/Component.ts +++ b/src/dom_components/model/Component.ts @@ -1590,7 +1590,8 @@ export default class Component extends StyleableModel { forEach(props, (value, key) => { const skipProps = ['classes', 'attributes', 'components']; if (key[0] !== '_' && skipProps.indexOf(key) < 0) { - attributes[`data-gjs-${key}`] = isArray(value) || isObject(value) ? JSON.stringify(value) : value; + attributes[`data-gjs-${key}`] = + isArray(value) || isObject(value) ? JSON.stringify(value) : isBoolean(value) ? `${value}` : value; } }); } diff --git a/test/specs/dom_components/model/Component.ts b/test/specs/dom_components/model/Component.ts index bcbdb78799..51b4b19e8f 100644 --- a/test/specs/dom_components/model/Component.ts +++ b/test/specs/dom_components/model/Component.ts @@ -152,7 +152,7 @@ describe('Component', () => { obj = new Component({}, compOpts); obj.set({ bool: true, - boolf: false, + removable: false, string: 'st\'ri"ng', array: [1, 'string', true], object: { a: 1, b: 'string', c: true }, @@ -165,12 +165,12 @@ describe('Component', () => { let resStr = "st'ri"ng"; let resArr = '[1,"string",true]'; let resObj = '{"a":1,"b":"string","c":true}'; - let res = `
`; + let res = `
`; expect(obj.toHTML({ withProps: true })).toEqual(res); resStr = 'st'ri"ng'; resArr = '[1,"string",true]'; resObj = '{"a":1,"b":"string","c":true}'; - res = `
`; + res = `
`; expect(obj.toHTML({ withProps: true, altQuoteAttr: true })).toEqual(res); });