Opened 17 years ago
Closed 12 years ago
#1236 closed Bug (fixed)
Unquoted keys in JavaScript objects got compressed by FCKpackager
Reported by: | Martin Kou | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | Project : CKPackager | Version: | |
Keywords: | Cc: |
Description
This bug have caused bug #1158 in FCKeditor, which appeared only in the built version.
A test case for the bug can be found below:
var key1 = "hack"; var key2 = "and"; var key3 = "slash"; var key4 = "rpg"; var obj = {key1: 'hack', key2: 'and', key3: 'slash', key4: 'rpg'}; alert( [obj.key1, obj.key2, obj.key3, obj.key4].join(' ')) ;
While the variable identifiers, key1-4 can be compressed to A to D, the object keys of the same names in obj cannot be compressed to A to D as well. However, the FCKpackager's behavior observed from bug #1158 was to compress the above code as follow:
var A="hack";var B="and";var C="slash";var D="rpg";var obj={A:'hack',B:'and',C:'slash',D:'rpg'};alert([obj.key1,obj.key2,obj.key3,obj.key4].join(' '));
Which is incorrect and changed the code's behavior.
Change History (4)
comment:1 Changed 17 years ago by
comment:2 Changed 17 years ago by
Keywords: | Pending WorksForMe added |
---|
I've used the current version and the result is:
var key1="hack";var key2="and";var key3="slash";var key4="rpg";var obj={key1:'hack',key2:'and',key3:'slash',key4:'rpg'};alert([obj.key1,obj.key2,obj.key3,obj.key4].join(' '));
comment:3 Changed 17 years ago by
Keywords: | Confirmed added; Pending WorksForMe removed |
---|
The test case must be inside a function to see the problem:
function() { var key1 = "hack"; var key2 = "and"; var key3 = "slash"; var key4 = "rpg"; var obj = {key1: 'hack', key2: 'and', key3: 'slash', key4: 'rpg'}; alert( [obj.key1, obj.key2, obj.key3, obj.key4].join(' ')) ; }
Results:
function(){var A="hack";var B="and";var C="slash";var D="rpg";var E={A:'hack',B:'and',C:'slash',D:'rpg'};alert([E.key1,E.key2,E.key3,E.key4].join(' '));}
comment:4 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | confirmed → closed |
This issue expired since we use Google Closure Compiler.
We must verify that variable names are not succeeded by a colon.