Dear Planet,
I feel like writing a bit about what I did for kjs, only about the new features (ignore bug fixes for now).
Let’s start with the things I already got in a released version:
– Array.isArray
– Object.prototypeOf
– Object.keys
– Object.getOwnPropertyNames
– String.trim, trimLeft, trimRight
Not that much hm?
Now let’s look at the Stuff I am trying to get in for 4.9.2:
– JSON.parse
– JSON.stringify
still not much…
And the rest with is implemented but still needs cleanup, or review, or something else to get in:
– Object.getOwnPropertyDescriptor
– Object.defineProperty
– Object.defineProperties (blocked by Object.defineProperty)
– Object.isExtensible (mainly blocked by Object.defineProperty)
– Object.preventExtensible (mainly blocked by Object.defineProperty)
– Object.seal (mainly blocked by Object.defineProperty)
– Object.isSealed (mainly blocked by Object.defineProperty)
– Object.freeze (mainly blocked by Object.defineProperty)
– Object.isFrozen (mainly blocked by Object.defineProperty)
– Object.create (blocked by Object.defineProperty)
– Date.toISOString
– Date.toJSON
Ok, that’s a bit more.
With the already present functions, that would nearly complete ECMAScript Edition 5. Doesn’t sound bad, huh?
But still, with all those new functions (and some bugfixes), kjs has no chance to rule the web-world.
Why? It’s not because it is too slow, or some other major bugs that keep websites from working. The reason is much simpler…
Let me show you the problem by (I think) simple js code, taken from battle.net (reduced).
var version;
if (browser == 'ff')
version = /firefox\\/([-.0-9]+)/.exec(userAgent);
else if (browser == 'ie')
version = /msie ([-.0-9]+)/.exec(userAgent);
else if (browser == 'chrome')
version = /
chrome\\/([-.0-9]+)/.exec(userAgent);
else if (browser == 'opera')
version = /opera\\/([-.0-9]+)/.exec(userAgent);
else if (browser == 'safari')
version = /safari\\/([-.0-9]+)/.exec(userAgent);
UserAgent.version = version[1].substring(0, 1);
“version” is still undefined for khtml/kjs. And trying to access undefined[1] will cause an exception, so that’s it for kjs, the exception is not caught and all the following JavaScript code will never be executed.
So the main reason is, kjs/khtml fails at the browser detection…
This could be solved if they add a sane “else”. Talking about sane “else”, there are really many websites that have an else in this case. But many of them have an insane else, which means hitting non-standard-javascript code, code that only one browser ever supported.
Maybe you are thinking, “oh come on.. that only happens on some exotic websites”, and I wish that was the case. But it’s not. I looked at SOME websites why they don’t work with khtml/kjs, from the JavaScript point of view, and for the last 30 of them this was the case, and that’s for some pretty big websites.
NOTE: Not for all websites it’s so easy to find the core problem, sometimes it looks very different at the beginning.
So that’s it, no matter how fast or how bugfree kjs/khtml will become, it will never work this those websites.
P.S.: I know you can change the browser detection in konqueror, but that is not a solution for the users.
Leave a Reply