Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding xmlns #268

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";

export const impl: Partial<RendererImpl<Node, string>> = {
scope(xmlns: string | undefined, tag: string | symbol): string | undefined {
// TODO: Should we handle xmlns???
scope(
xmlns: string | undefined,
tag: string | symbol,
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 {
switch (tag) {
case Portal:
case "foreignObject":
brainkim marked this conversation as resolved.
Show resolved Hide resolved
xmlns = undefined;
break;
case "svg":
xmlns = SVG_NAMESPACE;
break;
}

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

create(
Expand Down
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
Loading