mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] qweb: properly handle empty class attribute
The classList.add method actually crashes when given an empty string (or a string with just white spaces). closes #530
This commit is contained in:
@@ -46,6 +46,16 @@ describe("static templates", () => {
|
||||
expect(renderToString(qweb, "test")).toBe("<div>word</div>");
|
||||
});
|
||||
|
||||
test("div with a class attribute", () => {
|
||||
qweb.addTemplate("test", `<div class="abc">word</div>`);
|
||||
expect(renderToString(qweb, "test")).toBe(`<div class="abc">word</div>`);
|
||||
});
|
||||
|
||||
test("div with a empty class attribute", () => {
|
||||
qweb.addTemplate("test", `<div class="">word</div>`);
|
||||
expect(renderToString(qweb, "test")).toBe(`<div>word</div>`);
|
||||
});
|
||||
|
||||
test("div with a span child node", () => {
|
||||
qweb.addTemplate("test", "<div><span>word</span></div>");
|
||||
expect(renderToString(qweb, "test")).toBe("<div><span>word</span></div>");
|
||||
@@ -432,6 +442,18 @@ describe("attributes", () => {
|
||||
expect(result).toBe(`<div foo="bar"></div>`);
|
||||
});
|
||||
|
||||
test("dynamic class attribute", () => {
|
||||
qweb.addTemplate("test", `<div t-att-class="c"/>`);
|
||||
const result = renderToString(qweb, "test", { c: "abc" });
|
||||
expect(result).toBe(`<div class="abc"></div>`);
|
||||
});
|
||||
|
||||
test("dynamic empty class attribute", () => {
|
||||
qweb.addTemplate("test", `<div t-att-class="c"/>`);
|
||||
const result = renderToString(qweb, "test", { c: "" });
|
||||
expect(result).toBe(`<div></div>`);
|
||||
});
|
||||
|
||||
test("dynamic attribute with a dash", () => {
|
||||
qweb.addTemplate("test", `<div t-att-data-action-id="id"/>`);
|
||||
const result = renderToString(qweb, "test", { id: 32 });
|
||||
|
||||
Reference in New Issue
Block a user