Skip to content

Commit a1fcd03

Browse files
authored
Disable convertStyleToAttrs plugin by default (#1365)
Ref #1362 #1360 From the [spec](https://www.w3.org/TR/SVG11/styling.html#UsingPresentationAttributes): > Presentation attributes have lower priority than other CSS style rules specified in author style sheets or ‘style’ attributes. Though we replace inline styles with attributes without checking if thare is any `<style>` element. This makes the plugin unsafe and it should not be enabled by default.
1 parent a855b40 commit a1fcd03

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

plugins/convertStyleToAttrs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports.type = 'perItem';
44

5-
exports.active = true;
5+
exports.active = false;
66

77
exports.description = 'converts style to attributes';
88

test/svgo/_index.js

+5
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,9 @@ describe('svgo', () => {
6161
const result = optimize('<svg />', { input: 'file', path: 'input.svg' });
6262
expect(result.data).to.equal('<svg/>');
6363
});
64+
it('should preserve style specifity over attributes', async () => {
65+
const [original, expected] = await parseFixture('style-specifity.svg');
66+
const result = optimize(original, { input: 'file', path: 'input.svg', js2svg: { pretty: true } });
67+
expect(normalize(result.data)).to.equal(expected);
68+
});
6469
});

test/svgo/style-specifity.svg

+17
Loading

0 commit comments

Comments
 (0)