Skip to content

Commit

Permalink
fix(inlineStyles): case insensitive style props (#1797)
Browse files Browse the repository at this point in the history
Style property names are case-insensitive, for example `fill`, `FILL`,
and `FiLl` are all valid but refer to the same property. So when
inlining styles, we compare the lowercase strings and only use the last
instance of the property rather than embed them all.
  • Loading branch information
SethFalco authored Sep 25, 2023
1 parent 42f7752 commit 7e99c0b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/inlineStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ exports.fn = (root, params) => {
csstree.walk(styleDeclarationList, {
visit: 'Declaration',
enter(node, item) {
styleDeclarationItems.set(node.property, item);
styleDeclarationItems.set(node.property.toLowerCase(), item);
},
});
// merge declarations
Expand Down
2 changes: 0 additions & 2 deletions test/regression.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ const runTests = async ({ list }) => {
name === 'w3c-svg-11-test-suite/svg/filters-composite-05-f.svg' ||
// removing wrapping <g> breaks :first-child pseudo-class
name === 'w3c-svg-11-test-suite/svg/styling-pres-04-f.svg' ||
// messed case insensitivity while inlining styles
name === 'w3c-svg-11-test-suite/svg/styling-css-10-f.svg' ||
// rect is converted to path which matches wrong styles
name === 'w3c-svg-11-test-suite/svg/styling-css-08-f.svg' ||
// external image
Expand Down

0 comments on commit 7e99c0b

Please sign in to comment.