add support for boolean properties, such as 'checked'

fix #5
This commit is contained in:
Géry Debongnie
2019-03-20 13:16:12 +01:00
parent 5da7df8bf0
commit 9baf3ad4a7
4 changed files with 140 additions and 1 deletions
+29
View File
@@ -886,3 +886,32 @@ describe("loading templates", () => {
expect(qweb.processedTemplates).toEqual({});
});
});
describe("special cases for some boolean html attributes/properties", () => {
test("input type= checkbox, with t-att-checked", () => {
qweb.addTemplate("test", `<input type="checkbox" t-att-checked="flag"/>`);
const result = renderToString(qweb, "test", { flag: true });
expect(result).toBe(`<input type="checkbox" checked="">`);
});
test("various boolean html attributes", () => {
// the unique assertion here is the code snapshot automatically done by
// renderToString
expect.assertions(1);
qweb.addTemplate(
"test",
`
<div>
<input type="checkbox" checked="checked"/>
<input checked="checked"/>
<div checked="checked"/>
<div selected="selected"/>
<option selected="selected" other="1"/>
<input readonly="readonly"/>
<button disabled="disabled"/>
</div>
`
);
renderToString(qweb, "test", { flag: true });
});
});