GoogleChromeLabs / css-paint-polyfill

CSS Custom Paint / Paint Worklet polyfill with special browser optimizations.
https://googlechromelabs.github.io/css-paint-polyfill/
Apache License 2.0
740 stars 21 forks source link

Only the first paint is picked up #4

Closed nbremer closed 5 years ago

nbremer commented 5 years ago

Hi,

I noticed that only the first paint(something) was picked up out of my css, where I had created more than one different paint class. Adding a g to the regex from escapePaintRules seems to fix this issue for me:

function escapePaintRules(css) {
    return css.replace(/(;|,|\b)paint\s*\(\s*(['"]?)(.+?)\2\s*\)(;|,|!|\b)/g, '$1url(data:image/paint-$3,=)$4');
}
developit commented 5 years ago

Nice catch!