Description
In the current spec custom elements can only be in the namespace http://www.w3.org/1999/xhtml
and without using is=""
derive from HTMLElement
. It is desirable to have custom elements in other namespaces
- Create custom SVG elements in the SVG namespace which derive from
SVGElement
- Create elements in your own namespace using XHTML which derive from
Element
My proposal is to add a ‘namespace’ property to ElementDefinitionOptions to specify in which namespace the custom element should be placed. I created an issue before for Custom Elements v0.
Advantages
- Custom element name clashes will no longer occur
- If the namespace isn't a standard namespace (e.g. http://www.w3.org/1999/xhtml or http://www.w3.org/2000/svg) the dash requirement for new custom element tag names can be removed. Updated according to ExE-Boss
- Possible to implement polyfills for XML dialects such as XForms, MathML or X3D
References
"Distributed Extensibility: Finally Done Right?" in XML Prague 2014 proceedings
Are web components seriously not namespaced? on the w3c mailing list
Implementation
https://github.com/hfmanson/custom-elements/tree/namespace-aware is a fork that implements this feature. A live demo is at http://mansoft.nl/custom-elements/
This polyfill needs to be run on a browser that does not support Custom Elements natively, e.g. Microsoft Edge or Firefox 58.