Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 2x 2x 2x 2x | const { SLICE } = require('../utils.js')
const RegReferencesUrl = /\burl\((("|')?#(.+?)\1)?\)/
/**
* removeGradient 去除渐变 url('#id') 引用方法
* @param {*} Doc
*/
const removeGradient = Doc => {
SLICE.call(Doc.documentElement.childNodes).forEach(node => {
if (node.nodeName.toUpperCase() === 'PATH') {
if (
node.hasAttribute('fill') &&
RegReferencesUrl.test(node.getAttribute('fill'))
) {
node.removeAttribute('fill')
}
}
})
}
exports.fn = removeGradient
|