svgo
svgo copied to clipboard
removeXMLSpace plugin: remove xml:space attribute for inline svg usage
xml:space attribute has been deprecated according to MDN.
SVG supports the built-in XML xml:space attribute to handle whitespace characters inside elements. Child elements inside an element may also have an xml:space attribute that overrides the parent's one.
Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xml:space
Is this something that will be implemented in a near release?
@TrySound Any plans to merge this?
We have a dedicated plugin for removing deprecated attributes in main, so if you're removing it because it's deprecated, you can use that instead. It will be part of the next release.
It will be enabled by default, but will only remove safe attributes. Deprecated attributes that may impact rendering will only be removed if the removeAny parameter is passed.
See:
- https://github.com/svg/svgo/pull/1869
It could be worth having a safe plugin that removes xml:space="preserve" when it's safe to do, for example, when the text/cdata doesn't contain content that would be impacted by the attribute. However, we should be able to favor removeDeprecatedAttrs over a plugin that indiscriminately removes the attribute. Especially when we consider in most cases, including your example, SVGO was already removing it as default is the default value.