Skip to content

Commit 0b19aa6

Browse files
committed
align with dom-expressions
1 parent 4a954e7 commit 0b19aa6

4 files changed

Lines changed: 21 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ Example: https://codesandbox.io/s/solid-stale-resource-y3fy4l
460460
The Babel plugin now allows configuring multiple custom renderers at the same time. The primary case it is so a developer can still lever Solid's optimized DOM compilation while using their custom renderer. To make this work specify the tags each renderer is reponsible for. It will try to resolve them in order.
461461

462462
```js
463-
import { HTMLElements, SVGElements } from "solid-js/web";
463+
import { HTMLElements, SVGElements, MathMLElements } from "solid-js/web";
464464
let solidConfig = {
465465
moduleName: "solid-js/web",
466466
// @ts-ignore
@@ -469,7 +469,7 @@ let solidConfig = {
469469
{
470470
name: "dom",
471471
moduleName: "solid-js/web",
472-
elements: [...HTMLElements, ...SVGElements]
472+
elements: [...HTMLElements, ...SVGElements, ...MathMLElements]
473473
},
474474
{
475475
name: "universal",

packages/solid-h/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import {
66
insert,
77
createComponent,
88
dynamicProperty,
9-
SVGElements
9+
SVGElements,
10+
MathMLElements,
11+
Namespaces
1012
} from "@solidjs/web";
1113

1214
const h: HyperScript = createHyperScript({
@@ -15,7 +17,9 @@ const h: HyperScript = createHyperScript({
1517
insert,
1618
createComponent,
1719
dynamicProperty,
18-
SVGElements
20+
SVGElements,
21+
MathMLElements,
22+
Namespaces
1923
});
2024

2125
export default h;

packages/solid-html/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import {
1414
setAttribute,
1515
setAttributeNS,
1616
addEventListener,
17-
Properties,
1817
ChildProperties,
1918
DelegatedEvents,
2019
SVGElements,
21-
SVGNamespace
20+
MathMLElements,
21+
Namespaces,
2222
} from "@solidjs/web";
2323

2424
const html: HTMLTag = createHTML({
@@ -35,11 +35,11 @@ const html: HTMLTag = createHTML({
3535
setAttribute,
3636
setAttributeNS,
3737
addEventListener,
38-
Properties,
3938
ChildProperties,
4039
DelegatedEvents,
4140
SVGElements,
42-
SVGNamespace
41+
MathMLElements,
42+
Namespaces,
4343
});
4444

4545
export default html;

packages/solid-web/src/index.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {
33
insert,
44
spread,
55
SVGElements,
6+
MathMLElements,
7+
Namespaces,
68
hydrate as hydrateCore,
79
render as renderCore
810
} from "./client.js";
@@ -47,12 +49,13 @@ export * from "./server-mock.js";
4749

4850
export const isServer: boolean = false;
4951
export const isDev: boolean = "_SOLID_DEV_" as unknown as boolean;
50-
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
5152

52-
function createElement(tagName: string, isSVG = false, is = undefined): HTMLElement | SVGElement {
53-
return isSVG
54-
? document.createElementNS(SVG_NAMESPACE, tagName)
55-
: document.createElement(tagName, { is });
53+
function createElement(tagName: string, is = undefined): HTMLElement | SVGElement | MathMLElement{
54+
return SVGElements.has(tagName)
55+
? document.createElementNS(Namespaces.svg, tagName)
56+
: MathMLElements.has(tagName)
57+
? document.createElementNS(Namespaces.mathml, tagName)
58+
: document.createElement(tagName, { is });
5659
}
5760

5861
export const hydrate: typeof hydrateCore = (...args) => {
@@ -144,15 +147,13 @@ export function createDynamic<T extends ValidComponent>(
144147
return untrack(() => component(props));
145148

146149
case "string":
147-
const isSvg = SVGElements.has(component);
148150
const el = sharedConfig.hydrating
149151
? getNextElement()
150152
: createElement(
151153
component,
152-
isSvg,
153154
untrack(() => props.is)
154155
);
155-
spread(el, props, isSvg);
156+
spread(el, props);
156157
return el;
157158

158159
default:

0 commit comments

Comments
 (0)