\`);
+
+ return function template(ctx, node, key = \\"\\") {
+ let attr1 = {' a ':ctx['value']};
+ return block1([attr1]);
+ }
+}"
+`;
+
+exports[`attributes t-att-class with object 3`] = `
+"function anonymous(app, bdom, helpers
+) {
+ let { text, createBlock, list, multi, html, toggler, comment } = bdom;
+
+ let block1 = createBlock(\`
\`);
+
+ return function template(ctx, node, key = \\"\\") {
+ let attr1 = {' ':ctx['value']};
+ return block1([attr1]);
+ }
+}"
+`;
+
exports[`attributes t-attf-class 1`] = `
"function anonymous(app, bdom, helpers
) {
diff --git a/tests/compiler/attributes.test.ts b/tests/compiler/attributes.test.ts
index 616e7d1e..a0df18ab 100644
--- a/tests/compiler/attributes.test.ts
+++ b/tests/compiler/attributes.test.ts
@@ -63,6 +63,24 @@ describe("attributes", () => {
expect(result).toBe(`
`);
});
+ test("dynamic class attribute which is only a space", () => {
+ const template = `
`;
+ const result = renderToString(template, { c: " " });
+ expect(result).toBe(`
`);
+ });
+
+ test("dynamic class attribute with multiple consecutive spaces", () => {
+ const template = `
`;
+ const result = renderToString(template, { c: "a b" });
+ expect(result).toBe(`
`);
+ });
+
+ test("dynamic class attribute that starts and ends with a space", () => {
+ const template = `
`;
+ const result = renderToString(template, { c: " a " });
+ expect(result).toBe(`
`);
+ });
+
test("dynamic undefined generic attribute", () => {
const template = `
`;
const result = renderToString(template, { c: undefined });
@@ -260,6 +278,14 @@ describe("attributes", () => {
const template = `
`;
const result = renderToString(template, { b: true, d: false, f: true });
expect(result).toBe(`
`);
+ // leading and trailing space in the key
+ expect(renderToString(`
`, { value: true })).toBe(
+ '
'
+ );
+ // whitespace only key
+ expect(renderToString(`
`, { value: true })).toBe(
+ "
"
+ );
});
test("t-att-class with multiple classes", () => {
@@ -269,6 +295,10 @@ describe("attributes", () => {
expect(renderToString(`
`, { value: true })).toBe(
'
'
);
+ // multiple spaces between classes
+ expect(renderToString(`
`, { value: true })).toBe(
+ '
'
+ );
});
test("t-att-class with multiple classes, some of which are duplicate", () => {