kjs: variables with/without var [PATCH]

Harri Porten porten at kde.org
Sat Jan 18 21:07:04 GMT 2003


On Sat, 18 Jan 2003, David Faure wrote:

> Ouch, it seems the var was put in the wrong global object....
> (the one of the calling interpreter, i.e. the frameset, instead of the
> one of the frame

My understanding is different. The calling interpreter belongs to the
frame so I would assume the used global object to be the frame - no the
frameset.

> .... and since the frameset's globalobject isn't in the
> scope chain, the alert() can't find the value of 'myvar').

It should be there (see the scopeChain copy passed to DeclaredFunctionImp
in FuncDeclNode::procesFuncDecl). But according to what I believe the
variable ended up in another object (accomplished by your patch).

> Hmm, I'm afraid I don't see how putValue() could know the right
> globalobject to use.....

Me neither.

> or is that exec->context().imp()->variableObject() ?
> 
> Wow, it works!
> Harri, what do you think about this fix?

Sounds tempting but the spec has been proving us wrong in these matters
each time so far.

Does this patch satisfy the condition that an alert(top.myvar) in
frame.html works, too (NS 4.7) ? My khtml build is broken so I can't try.
But variableObject() should be the variable object created for function
execution which wouldn't be the same as the top object.

One would have to think of other ways of testing whether other browsers
maybe do switch the global object when executing functions defined in
another window.

Harri.






More information about the kfm-devel mailing list