Summary: | JavaScript for... in loses object order | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | bht |
Component: | kjs | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | RedHat Enterprise Linux | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
bht
2003-08-19 01:37:31 UTC
The ordering of properties is implementation dependent (see the standard). You shouldn't rely on it. If you want a fixed order do as you indicated above: use sort(). We might unify ordering of properties on day but it has to be done carefully in order not to decrease efficency. Harri, Thanks for examining this issue. Unfortunately, the standard is painfully unhelpful in this particular case. Please let me use a very relevant analogy from the SQL database domain: If you are familiar with SQL database technology then you will recognise that in this domain, things are standardised and handled correctly: The SQL "SELECT * FROM MY_TABLE;" lists the contents of "MY_TABLE" in exactly the same column order as the fields were defined in the data definition language (DDL). Even in the DDL itself, when you add a field to an existing table layout, then it gets appended to the end of the layout, preserving the column order. As you know, the ECMA standard was only created AFTER thwo fairly solid JavaScript implementations existed for a significant period of browser history. Today on the web, for commercial applications, and I hate to say that for various other reasons, it is more practical to follow what Microsoft Internet Explorer and Netscape implement than what the standards are because these browsers cover more than 90% of all browsers on the web today. Because of this, it is not practical to penalise 90% of users with additional code only to accommodate nascent, incomplete technology. I am saying "incomplete" with some emphasis. As you know, there are quite a few JavaScript commands in browsers that are not part of the standard. However, all modern browsers today implement them because without these, browsers would not be very useful at all: window.open, document.write, window.setTimeout to name just a few. Last not least I am referring to commercial browser based applications. These applications have been released and they will generate thousands of web sites. They definitely use the natural for ... in order for critiacl purposes, in other words they do not function at all with a browser that does not implement it. I admire and to some extent share the enthusiasm of the KDE team for their product. And I am very enthusiastic to support their work wherever I can. That is why I am writing testcases early, to ensure that Konqueror gets on board. Please fix this bug as soon as your resources permit it. |