Skip to content

Instantly share code, notes, and snippets.

@mathieudutour mathieudutour/sRGB-blur.js

Last active Jul 22, 2020
Embed
What would you like to do?
SVGO plugin to fix color space issue in Safari on SVG Filter primitives
'use strict';
exports.type = 'perItem';
exports.active = true;
exports.description = 'add color-interpolation-filters="sRGB" to filters';
exports.params = {
force: false,
key: 'color-interpolation-filters',
value: 'sRGB',
// https://developer.mozilla.org/en-US/docs/Web/SVG/Element#Filter_primitive_elements
tags: ['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'feSpecularLighting', 'feTile', 'feTurbulence']
};
exports.fn = function(item, params) {
if ((params.tags || []).every(function (tag) {
return !item.isElem(String(tag));
})) {
return;
}
if (!params.force && item.hasAttr(String(params.key))) {
return
}
if (!item.attrs) {
item.attrs = {}
}
item.attrs[String(params.key)] = {
name: String(params.key),
value: String(params.value),
prefix: '',
local: String(params.key)
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.