Skip to content

Commit

Permalink
Add test, fix PR based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
canadaduane committed Nov 7, 2023
1 parent 757abf0 commit 4ac5d8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ export const impl: Partial<RendererImpl<Node, string>> = {
scope(
xmlns: string | undefined,
tag: string | symbol,
props: any
props: Record<string, any>

Check failure on line 17 in src/dom.ts

View workflow job for this annotation

GitHub Actions / build

Insert `,`
): string | undefined {
// TODO: Should we handle xmlns???
switch (tag) {
case Portal:
xmlns = undefined;
Expand All @@ -26,7 +25,7 @@ export const impl: Partial<RendererImpl<Node, string>> = {
break;
}

return props?.xmlns ?? xmlns;
return props.xmlns || xmlns;
},

create(
Expand Down Expand Up @@ -74,7 +73,7 @@ export const impl: Partial<RendererImpl<Node, string>> = {
}

// TODO: extract props from nodes
return {props, children};
return { props, children };

Check failure on line 76 in src/dom.ts

View workflow job for this annotation

GitHub Actions / build

Replace `·props,·children·` with `props,·children`
},

patch(
Expand Down Expand Up @@ -106,7 +105,7 @@ export const impl: Partial<RendererImpl<Node, string>> = {
style.cssText = "";
}

for (const styleName in {...(oldValue as {}), ...(value as {})}) {
for (const styleName in { ...(oldValue as {}), ...(value as {}) }) {

Check failure on line 108 in src/dom.ts

View workflow job for this annotation

GitHub Actions / build

Replace `·...(oldValue·as·{}),·...(value·as·{})·` with `...(oldValue·as·{}),·...(value·as·{})`
const styleValue = value && (value as any)[styleName];
if (styleValue == null) {
style.removeProperty(styleName);
Expand Down Expand Up @@ -383,6 +382,6 @@ export const renderer = new DOMRenderer();

declare global {
module Crank {
interface EventMap extends GlobalEventHandlersEventMap {}
interface EventMap extends GlobalEventHandlersEventMap { }

Check failure on line 385 in src/dom.ts

View workflow job for this annotation

GitHub Actions / build

Delete `·`
}
}
11 changes: 8 additions & 3 deletions test/svg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ test("foreignObject", () => {
document.body,
);
Assert.ok(document.body.firstChild instanceof SVGElement);
Assert.ok(
document.body.firstChild!.firstChild!.firstChild instanceof HTMLElement,
);

const foreignObject = document.body.firstChild!.firstChild!;
Assert.ok(foreignObject instanceof SVGElement);
Assert.is(foreignObject.namespaceURI, "http://www.w3.org/2000/svg");

const div = foreignObject.firstChild! as HTMLElement;
Assert.ok(div instanceof HTMLElement);
Assert.is(div.namespaceURI, "http://www.w3.org/1999/xhtml");
});

test("classes", () => {
Expand Down

0 comments on commit 4ac5d8b

Please sign in to comment.