As a side-effect, this also makes Jangaroo run on older browsers based on KHTML or WebKit (tested under Linux with Konqueror 3.4), and as an even better side effect, I was now able to get my Jangaroo-based Tron Lightcycle game Jangaron running on the iPhone, too! Since the iPhone is missing the keys needed to control your Lightcycle in the game, I have set up a special iPhone version with on-screen buttons -- feel invited to go ahead and try!
So what was the problem with Jangaroo and old KHTML / WebKit versions? There were several bugs in the KHTML / WebKit JavaScript engine we had to work around:
- When using new Function(), it was not possible to set the prototype property, while with function(){}, it works as expected.
- with() seems to behave differently when setting properties of the "withed" object. Avoid it to be really cross-browser compatible!
- delete obj.property showed strange behavior: it seems that in some cases, the property is deleted from the prototype (i.e. for all instances!) instead of from obj only. We also refrained from using it in the runtime.
- In order to keep compiled code as close as possible to the source code, we tried to retrieve the generated function's name at runtime. Unfortunately, in older KHTML / WebKit versions there seems no way to do so: Firefox's Function#name is not defined and Function#toString() returns the whole source code of the function save its name. Thus, we had to change the runtime method syntax slightly, sacrificing a bit code similarity for better browser compatibility. For example, the compilation output of a JS2 method
public function foo(x) { }
was
"public", function foo(x) { }
and now looks like this:
"public foo", function(x) { }
or like this in debug mode:
"public foo", function foo(x) { }
Speaking of performance: the Jangaroo compiler update also increased performance for some common special cases. Sounds contradictory, but there are "common special cases", i.e. special code patters that still occur quite often, like the fly-weight pattern: simple classes that have many instances. We optimized the Jangaroo runtime (Class.js) so that for classes which refrain from using field initializers and/or inheritance, there is a measurable speed-up that leaves almost no performance penalty compared to manually created JavaScript 1.x code.
Have fun with the increased browser-compatible, performance-optimized new Jangaroo version! We are eager to hear about your opinion and discuss your suggestions, so please don't hesitate to comment!