You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c452850
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(web): dynamic() honors xmlns when creating a tag-name element (#3386) (#3436)
* fix(web): dynamic() honors xmlns when creating a tag-name element (#3386)
The compiler resolves a tag's namespace from its parent at build time; the
dynamic() runtime path creates the element before it has a parent, so a tag
that exists in both HTML and SVG (a, script, style, title) was always an HTML
element — `<svg><Link href/></svg>` with `Link = dynamic(() => "a")` produced
an HTML anchor inside the SVG tree (#3386 part 2).
The instance now says which namespace it means with the attribute compiled
JSX already uses for exactly this (`<a xmlns="http://www.w3.org/2000/svg">`).
Like `is`, `xmlns` is an attribute of the element that also decides how the
node is created: read once, untracked, at creation — the DOM can't
re-namespace a node — then applied through spread() as an ordinary attribute,
so a client-rendered element carries the same attribute the server serializes
and the parser keeps. Server: nothing to do; ssrElement already emits it, and
hydration claims the parser-namespaced node. Without xmlns the namespace is
still inferred from the tag.
Types: dynamic() returns Component<DynamicComponentProps<T>>, adding
`xmlns?: string` for tag-name targets only (the ambiguous tags' intrinsic
attribute types are the HTML ones, which lack it).
Tests: namespaceURI with/without xmlns inside <svg> and <math>, inference
still wins for unambiguous tags, xmlns overrides inference both ways, <Dynamic>
parity, read-once (later values update the attribute, never the node); server
output byte-equal to compiled `<a xmlns>`; parity-harness scenario hydrating a
dynamic() <a xmlns> inside <svg>. Also pins ref arrays through spread into a
dynamic() tag (the shape Kobalte's solid2 branch works around at rc.3) as
working on next.
Co-authored-by: Cursor <[email protected]>
* fix(web): accept xmlns on every element's attribute type
CI test-types rejected the compiled-JSX comparison `<a xmlns={SVG} href>`:
`AnchorHTMLAttributes` had no `xmlns` — the compiler has honored `<a xmlns=…>`
on any tag all along (it's how it disambiguates a/script/style/title), so
the attribute belongs on the shared `ElementAttributes`, not only SVG/MathML.
Source of truth is jsx-h.d.ts; jsx.d.ts and @solidjs/h's copy are regenerated.
With every intrinsic's attribute type carrying `xmlns`, dynamic()'s tag-name
components inherit it and the conditional `DynamicComponentProps` /
`DynamicElementProps` types from the previous commit are unnecessary — drop
them; dynamic() returns Component<ComponentProps<T>> as before.
Co-authored-by: Cursor <[email protected]>
* fix(web): scope xmlns type to the HTML/SVG-ambiguous tags
Narrow the previous commit: instead of accepting xmlns on every element via
ElementAttributes, keep it on SVGAttributes/MathMLAttributes and add it only
to the four tags that exist in both HTML and SVG (a, script, style, title).
Those are the only tags where the attribute changes what gets created, both
in the compiler and in dynamic(). Introduces TitleHTMLAttributes so title has
a home for it. Regenerates the web and h JSX types.
Co-authored-by: Claude via Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
---------
Co-authored-by: Cursor <[email protected]>
Co-authored-by: Claude via Cursor <[email protected]>
`dynamic()` / `Dynamic` with a tag-name source honor an `xmlns` prop when creating the element (#3386)
7
+
8
+
The compiler resolves a tag's namespace from its parent at build time; the `dynamic()` runtime path creates the element before it has a parent, so a tag that exists in both HTML and SVG (`a`, `script`, `style`, `title`) was always created as an HTML element — `<svg><Link href=…/></svg>` with `Link = dynamic(() => "a")` produced an HTML anchor inside the SVG tree. The instance can now say which one it means with the same attribute compiled JSX uses for the same purpose: `<Link xmlns="http://www.w3.org/2000/svg" href=…/>`. Like `is`, `xmlns` is read once, untracked, at creation (the DOM can't re-namespace a node) and then applied as an ordinary attribute, so a client-rendered element carries the same attribute the server serializes. Without `xmlns` the namespace is still inferred from the tag name. Hydration is unaffected: it claims the parser-namespaced node.
9
+
10
+
Types: `xmlns` is now accepted on the four tags that exist in both HTML and SVG (`a`, `script`, `style`, `title`) in addition to the SVG/MathML attribute sets that already had it — those are the only tags where the attribute changes what gets created, and the compiler has honored `<a xmlns=…>` on them all along. Unambiguous HTML tags (`div`, `span`, …) still reject it. `dynamic()`'s tag-name components inherit it through their intrinsic attribute types. Also syncs `@solidjs/h`'s generated JSX types.
0 commit comments