Fixing a bug in my js1k entries
28 de Marzo del 2013There was a problem in my code in my two js1k entries for this year (this and this). They weren’t showing the bee’s wings in latest Chrome - that I installed just today - and it was reported of having other problems in Firefox nightly. Note that by the time you read this, the organizer of js1k might have updated the code with my bug-fix and it might look right again.
So what was the problem? For js1k size coding, it is very common to try to save every single byte/character as possible, even if it results in ugly and/or unreadable code. One of the ways to do it is by placing code inside function calls without parameters, just to avoid the use an additional semicolon. So I had this:
a.fill( /* some code here */ );
With a being a Canvas 2D Context. So, why it is not working on the latest browsers right? The reason is simple: Canvas 2D Context spec is just a working draft, the draft changed and the new browsers are adapting to it.
Previous, the fill method had a single functionality, and no parameters. Now fill accepts an optional path parameter. Without parameters it works as previously, with parameters it doesn’t.
So, the bug-fix was easy; just to place the code inside fill outside it. I believe this problem will be happening in more than one js1k entries, as it is a very common size optimization.
Interesting that, if I understood correctly, Firefox and Chrome would be “synchronized” in their updating of spec like this… or is this maybe part of some component they share?
Yeah, it’s an unfortunate but inevitable case that some demo’s will stop working over time. Some because they rely on api’s that evolve and change, some (like the first winner) because they rely on object property enumeration order, some… simply because they do.
Would be awesome if there was an easy way to make gif-animations for each demo for prosperity. Not happening right now though.
Pete, what about capturing them automatically to Youtube? Maybe a browser extension is able to catch the video/audio?