Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions plugins/minifyStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,13 @@ export const fn = (_root, { usage, ...params }) => {
for (const node of elementsWithStyleAttributes) {
// style attribute
const elemStyle = node.attributes.style;
node.attributes.style = csso.minifyBlock(elemStyle, {
...params,
}).css;
try {
node.attributes.style = csso.minifyBlock(elemStyle, {
...params,
}).css;
} catch {
/** ignore style syntax errors */
}
}
},
},
Expand Down
13 changes: 13 additions & 0 deletions test/plugins/minifyStyles.12.svg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Ensure plugin works with syntactically incorrect style attributes.

===

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 225 425">
<path style="fill- opacity:0.5" d="M0 50 l50 50 0 20z"/>
</svg>

@@@

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 225 425">
<path style="fill- opacity:0.5" d="M0 50 l50 50 0 20z"/>
</svg>