Re:It's always been you, Canvas2D
by MatmaRex on Friday March 04, 2022 @09:35AM
(#30555335)
There are some getters and setters in the web APIs with cheeky side effects. Presumably this one causes the canvas to be re-created, or something. Here's another good one, try it in your browser console:
[ Parent
| on HN ]
Re:It's always been you, Canvas2D
by tentacleuno on Friday March 04, 2022 @12:07PM
(#30557387)
Your trick doesn't work for me in Firefox 96 :)
One more: If you set an image's src attribute to the same thing, it'll still reload the image.
const image = new Image("/img.png");
document.body.append(image);
image.src = image.src;It might not actually reload the image but it has to fire all the events as though it did otherwise code would hang.
Re:It's always been you, Canvas2D
by tentacleuno on Friday March 04, 2022 @06:34PM
(#30562064)
It does reload the image in Firefox at least. I just tried it.
Oh, it works, it's just cheekier than you think - it won't refresh the page if the URL includes a hash/fragment (such as after you clicked one of the "next" links while browsing comments here).