Skip to content

Commit

Permalink
fix: issue with html renderer, pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Desdaemon committed Apr 23, 2024
1 parent d9d87df commit d229acb
Show file tree
Hide file tree
Showing 5 changed files with 1,967 additions and 1,586 deletions.
89 changes: 51 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function htmlTransformChildren(value: InterpValue): string {
else if (isObject(value)) obj = value;
else return "";
const out: string[] = [];
for (const key in Object.keys(obj)) {
for (const key of Object.keys(obj)) {
const attr = (obj as Record<string, unknown>)[key];
if (!isRenderable(attr) && attr !== "") continue;
if (jsxConfig.jsonAttributes.has(key)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe("html templator", () => {
expect(<div hx-vals={{ foo: "It's joever" }} />).toBe(`<div hx-vals='{"foo":"It&#39;s joever"}'></div>`);
});
it("skips falsy attributes", () => {
expect(<div data-foo={false} {...{ foobar: false }} />).toBe("<div></div>");
expect(<div data-foo={false} {...{ foobar: false }} />).toBe("<div ></div>");
});
it("correctly handles void elements", () => {
expect(
Expand Down
10 changes: 5 additions & 5 deletions tests/static-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"license": "ISC",
"type": "module",
"dependencies": {
"@swc/core": "^1.3.78",
"@swc/jest": "^0.2.29",
"jest": "^29.6.2",
"swc-plugin-static-jsx": "^0.1.2",
"swc-plugin-static-jsx": "^0.2.0",
"@swc/core": "^1.4.16",
"@swc/jest": "^0.2.36",
"jest": "^29.7.0",
"typed-htmx": "link:../.."
},
"devDependencies": {
"@types/jest": "^29.5.3"
"@types/jest": "^29.5.12"
}
}
Loading

0 comments on commit d229acb

Please sign in to comment.