Skip to content
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

feat(removeDeprecatedAttrs): new removeDeprecatedAttrs plugin #1869

Merged
merged 1 commit into from
Jan 15, 2024

Commits on Jan 4, 2024

  1. feat(removeDeprecatedAttrs): new removeDeprecatedAttrs plugin

    The new removeDeprecatedAttributes removes deprecated attributes from
    the SVG document. For example, the "version" attribute on the "svg"
    element is deprecated and not recommended as documented on MDN:
    
    https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/version
    
    > 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.
    
    The document:
    
    ```
    <svg version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
      <rect x="10" y="10" width="80" height="80"/>
    </svg>
    ```
    
    Becomes:
    
    ```
    <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
      <rect x="10" y="10" width="80" height="80"/>
    </svg>
    ```
    
    The plugin has a concept of "safe" and "unsafe" deprecated attributes. A
    safe attribute is on that, when removed, does not alter the rendering.
    An example is the "version" attribute described above. An unsafe
    attribute is one that does change the rendering. By default, the plugin
    only removes the safe attributes. The param "removeUnsafe" can be used
    to also remove the unsafe ones.
    
    Deprecated attributes may also appear in the SVG stylesheet as a
    selector. When this occurs, the attribute won't be removed from the
    document to avoid additional rendering changes.
    
    The "xml:lang" attribute is deprecated but also has a replacement,
    "lang", so this attribute is treated as a special case and is safe when
    its replacement exists.
    
    The plugin is built for easy expansion as new deprecated attributes are
    discovered or announced. Simply add to ones of the "deprecated" sets in
    plugins/_collections.js.
    
    Fixes svg#1701
    jdufresne committed Jan 4, 2024
    Configuration menu
    Copy the full SHA
    2b3909a View commit details
    Browse the repository at this point in the history