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
Changes from 3 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
9 changes: 6 additions & 3 deletions src/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ import {
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 {
scope(
xmlns: string | undefined,
tag: string | symbol,
props: any
canadaduane marked this conversation as resolved.
Show resolved Hide resolved
): string | undefined {
// TODO: Should we handle xmlns???
canadaduane marked this conversation as resolved.
Show resolved Hide resolved
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optional chain operator ?. is unnecessary because props will always be defined. And as a stylistic thing, I’d prefer a boolean short-circuit over a nullish coalescing operator ?? insofar as the codebase doesn’t use it yet.

},

create(
Expand Down