Skip to content

includesAttrSelector: support different equality checks in attribute selectors too #2145

Open
@SethFalco

Description

@SethFalco

We have a helper function named includesAttrSelector. We use this to check if an attribute has been referenced in the stylesheet. If so, the plugin may have different behavior. Usually, by not removing that attribute because it may break styles otherwise.

However, our logic takes a very safe approach, of never deleting attributes if it's been referenced in CSS, even if the operator/check wouldn't match.

For example, suppose an element in an SVG had preserveAspectRatio="xMidYMid meet", with a CSS selector of [preserveAspectRatio^="y"].

This would not match, yet to be on the safe side, we will not remove the attribute. We do not actually check the operator and value, but only the key. Let's improve the logic to actually perform these checks so that we do remove the attribute when it's truly unnecessary.

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssue is approved and contributors new to SVGO/OSS are especially encouraged to try to resolve it.help wantedIssue is approved and anyone is encouraged to resolve it in a new pull request.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions