Subj : problem with string objects loosing their properties To : netscape.public.mozilla.jseng From : Helge Hess Date : Fri Jun 20 2003 02:24 pm Hi, I'm fighting some problem in my ObjC/JS bridge related to JS string objects losing their properties and functions. It only occurs in a certain context (difficult to explain), and I'm just searching for possible reasons instead of an answer ;-) OK, this is my test-case (you don't need to understand the ObjC ;-): ---snip--- id base; base = [[Blah alloc] init]; NSLog(@"base: %@", base); NSLog(@"this: %@", [base evaluateScript:@"this" language:SLANG]); NSLog(@"typeof this: %@", [base evaluateScript:@"typeof this" language:SLANG]); NSLog(@"'hello': %@", [base evaluateScript:@"'hello'" language:SLANG]); NSLog(@"typeof 'hello': %@", [base evaluateScript:@"typeof 'hello'" language:SLANG]); NSLog(@"'hello'.length: %@", [base evaluateScript:@"'hello'.length" language:SLANG]); NSLog(@"'hello'.length == null: %@", [base evaluateScript:@"'hello'.length==null" language:SLANG]); ---snap--- prints: ---snip--- Jun 20 11:16:37 testjs [22671]: base: Jun 20 11:16:37 testjs [22671]: this: Jun 20 11:16:37 testjs [22671]: typeof this: object Jun 20 11:16:37 testjs [22671]: 'hello': hello Jun 20 11:16:37 testjs [22671]: typeof 'hello': string Jun 20 11:16:37 testjs [22671]: 'hello'.length: Jun 20 11:16:37 testjs [22671]: 'hello'.length == null: 1 ---snap--- As one can see in the "typeof 'hello'" 'hello' is a JavaScript string. But it doesn't have a 'length' property or the 'length' property is null (the same goes for functions like slice()). I only grasp half of the SpiderMonkey internals - what should I search for, I can imagine that: a) a global-object is not properly set in the JSContext ? b) the custom "this" object doesn't have a proper "parent" object ? c) "some" prototype chain of 'hello' is broken ? d) somehow the standard-classes are not properly initialized e) .... What is likely, what could I search for ? What could be broken if a typeof reports a 'string' object but the object doesn't have any string properties ? After searching two nights any insight is welcome ;-) regards, Helge .