Skip to content

Commit

Permalink
fix html
Browse files Browse the repository at this point in the history
  • Loading branch information
djalmajr committed Apr 19, 2023
1 parent ec09383 commit 0ab0fc4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/html.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { set } from './set';
import { Obj } from './types';

const prefix = 'δ';
Expand All @@ -23,9 +22,9 @@ export function html(strings: string[], ...values: unknown[]) {
if (node.nodeType === Node.ELEMENT_NODE) {
const attrs = node.getAttributeNames().filter((n) => hasPfx(node.getAttribute(n)!));
for (attr of attrs) {
if (attr[0] === "@") set(`on${attr.slice(1)}`, values[idx++], node);
if (attr[0] === "@") (node as Obj)[`on${attr.slice(1)}`] = values[idx++];
else if (attr[0] === "?") node.toggleAttribute(attr.slice(1), !!values[idx++]);
else if (attr[0] === ".") set(attr.slice(1), values[idx++], node);
else if (attr[0] === ".") (node as Obj)[attr.slice(1)] = values[idx++];
else { node.setAttribute(attr, values[idx++] as never); continue; } // prettier-ignore
node.removeAttribute(attr);
}
Expand Down

0 comments on commit 0ab0fc4

Please sign in to comment.