From 4ac5d8b4bc8142ce8a06d8008339427009ea9731 Mon Sep 17 00:00:00 2001 From: Duane Johnson Date: Tue, 7 Nov 2023 09:43:58 -0700 Subject: [PATCH] Add test, fix PR based on feedback --- src/dom.ts | 11 +++++------ test/svg.tsx | 11 ++++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/dom.ts b/src/dom.ts index a650504f1..20759b78b 100644 --- a/src/dom.ts +++ b/src/dom.ts @@ -14,9 +14,8 @@ export const impl: Partial> = { scope( xmlns: string | undefined, tag: string | symbol, - props: any + props: Record ): string | undefined { - // TODO: Should we handle xmlns??? switch (tag) { case Portal: xmlns = undefined; @@ -26,7 +25,7 @@ export const impl: Partial> = { break; } - return props?.xmlns ?? xmlns; + return props.xmlns || xmlns; }, create( @@ -74,7 +73,7 @@ export const impl: Partial> = { } // TODO: extract props from nodes - return {props, children}; + return { props, children }; }, patch( @@ -106,7 +105,7 @@ export const impl: Partial> = { style.cssText = ""; } - for (const styleName in {...(oldValue as {}), ...(value as {})}) { + for (const styleName in { ...(oldValue as {}), ...(value as {}) }) { const styleValue = value && (value as any)[styleName]; if (styleValue == null) { style.removeProperty(styleName); @@ -383,6 +382,6 @@ export const renderer = new DOMRenderer(); declare global { module Crank { - interface EventMap extends GlobalEventHandlersEventMap {} + interface EventMap extends GlobalEventHandlersEventMap { } } } diff --git a/test/svg.tsx b/test/svg.tsx index 699637a4a..c26d15837 100644 --- a/test/svg.tsx +++ b/test/svg.tsx @@ -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", () => {