-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Introduce the foreign namespace to preserve attribute case and skip html specific a11y validations #5652
Introduce the foreign namespace to preserve attribute case and skip html specific a11y validations #5652
Conversation
I'm a bit wary about adding an official new namespace that is for use in specific third-party libraries, and which doesn't actually do anything useful without them, and which has a name that only makes sense in the context of these third-party libraries. This feels a bit like the hacky way |
@Conduitry Perhaps the Svelte compiler could instead expose a setting to specify how the casing of attributes should be handled? A value of As for accessibility, it could additionally expose an option to enable web accessibility checks, with the default value being |
Maybe better to have an namespace called
|
after speaking with @Conduitry it seems the a11y changes are the sticking point. I will remove the checks around a11y so I can get the case sensitivity thing in. I will also change the namespace to "external" and point the url at "https://svelte.dev/docs#svelte_options" |
That would be a great path forwards, thanks! Really looking forward to preserved attribute casing. I can live with accessibility warnings in the short term. |
96c027c
to
95ca937
Compare
I have changed the namespace to "external" and it now only impacts the attribute case, an alternative method for disabling warnings is in discussion |
5512b63
to
e13c0f7
Compare
As a result of previous discussion, this PR has been updated with the following changes
|
Is there anything under |
Good point. I added docs in three places, |
Allows the use of svelte for DOM implementations that aren't html5
5d1fbec
to
ad76a71
Compare
This has been released in 3.32.0 - thank you for your efforts and for your patience! |
What
Improve support for non HTML usage of svelte (eg Svelte Native and Svelte node-gui) by retaining the original attribute case when calling
setAttribute
(This supersedes #5387 as a more comprehensive solution)
Why
Svelte Native has been around since Svelte 3 providing support for writing native mobile applications in Svelte. Svelte node-gui is a new project which supports writing native desktop apps (Node-Gui/Qt) in Svelte.
Both projects require the original attribute case to set properties on their native elements. This is currently achieved by reflecting over the native objects to find the correct casing which is less than ideal.
How
Svelte Native has always injected a custom namespace
xmlns="tns"
into the top level element of a svelte component. This was needed to prevent svelte from generating.innerHtml =
code in the component. This PR introduces an official supported namespaceexternal
which allows tools handling non html5 dom to inject<svelte:options namespace="extermal" />
Like the custom handling that applies to elements that are in the SVG and other custom namespaces (eg MathML), the
external
namespace is used to opt out of attribute name lowercasing.Next Steps
If this PR lands, svelte-native and svelte node-gui etc will need to change themselves to insert a svelte options tag with namespace set to "external", and any code that normalizes that attribute names will need to be removed.
EDIT: This PR originally proposed a "native" namespace, and skipped a11y checks when present. The PR has been updated to add an "external" namespace to make it more general. It only impacts case sensitivity of attributes. A11y warnings for external namespaces will need to be solved in another manner