DEV Community

Cover image for 🎩 JavaScript Enhanced SCSS mixins! 🎩 - CSS element() function polyfill
Adam Crockett πŸŒ€
Adam Crockett πŸŒ€

Posted on β€’ Edited on

8 1

🎩 JavaScript Enhanced SCSS mixins! 🎩 - CSS element() function polyfill

I was sad to see that its been 8yrs and only Firefox supports css element().

Fortunately with the help of some clever scss and css variables. I have been able to implement a polyfill. There are some limitations and I would not call it performant but its not the worst I have ever seen.

I will see if I can get a better version working with the Paint Api.

You might be thinking, this is useless?

well compositing live blur effects would be fairly simple using this approach, something I have sort of done before in other pens but not as elegantly as this.

Top comments (3)

Collapse
 
retyui profile image
Davyd NRB β€’

You solution is useless when try to render iframe\img that use resources from another domain

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€ β€’

Hi David that's a pretty strong and damning statement πŸ€·β€β™‚οΈ I'm sorry your having a bad day?

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€ β€’ β€’ Edited

It's a pollyfill for a now defunct feature, let's be real it's not that usefull, and then theres this edge case where an Iframe which could literally do something like this is included I should expect it probably doesn't work no.

I am unsure what the limits of html to canvas are off the top of my head, something I read way back then mentions tainted canvas and iframe security yadeya it's been a while, I'm an old JavaScript ninja, give me a break πŸ˜‰. There are proposals for screenshot APIs to replace the use of that library.

All in all this was one of my most popular posts and I think it's fun which is therefore useful.

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere β€œthank you” often brightens someone’s dayβ€”share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay