includesAttrSelector: support different equality checks in attribute selectors too
#2,145 创建于 2025年6月21日
仓库指标
- Star
- (20,308 star)
- PR 合并指标
- (30 天内没有已合并 PR)
描述
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: