diff --git a/src/Widget.ts b/src/Widget.ts index 1fb425d..729b2dd 100644 --- a/src/Widget.ts +++ b/src/Widget.ts @@ -1,3 +1,5 @@ +import { replaceEntities } from "./helpers/attributeParser"; + abstract class Widget { /** * Default colspan @@ -153,9 +155,9 @@ abstract class Widget { } if (props.domain) { if (typeof props.domain !== "string") { - this._domain = JSON.stringify(props.domain); + this._domain = replaceEntities(JSON.stringify(props.domain)); } else { - this._domain = props.domain; + this._domain = replaceEntities(props.domain); } } if (props.widget_props) { diff --git a/src/spec/Widget.spec.ts b/src/spec/Widget.spec.ts index 2df8274..0c98c3d 100644 --- a/src/spec/Widget.spec.ts +++ b/src/spec/Widget.spec.ts @@ -26,6 +26,24 @@ describe("A Widget", () => { expect(typeof widget.colspan).toBe("number"); }); + + describe("Parsing domain", () => { + it("should parse domain with html entities when is a string", () => { + const props = { + domain: "[('date_start', '>', '2021-01-01')]", + }; + const widget = new WidgetImpl(props); + expect(widget.domain).toBe("[('date_start', '>', '2021-01-01')]"); + }); + it("should parse domain with html entities when is an object", () => { + const props = { + domain: [["date_start", ">", "2021-01-01"]], + }; + const widget = new WidgetImpl(props); + expect(widget.domain).toBe('[["date_start",">","2021-01-01"]]'); + }); + }); + describe("Parsing widget props", () => { it("should parse widget_props", () => { const props = {