executeScript(): KJS problem with "this" object
Harri Porten
porten@kde.org
Tue, 4 Feb 2003 13:09:12 +0100 (CET)
On Tue, 4 Feb 2003, Peter Kelly wrote:
> This looks like the way to go I think. The spec doesn't mention situations
> like this when you're executing code from the host environment and need
> to provide a this object, so as far as I can see this doesn't conflict
> with it.
I think what were are doing wrong: we treat code inside of <script> tags
and event handlers the same way. The optional "this" parameter was a hack
to accomplish this.
The real solution would be do evaluate global code as is and treat event
handlers as function calls where "this" is well defined.
> > [ It appears to me that none of the other types of code would do
> > (there is no activation object, and we want new variables to go into
> > the global object, so this is not FunctionCode/AnonymousCode;
> > EvalCode ignores thisV too, when a calling context is set. So the
> > only solution seems to be GlobalCode using thisV, as done below...) ]
Note that EvalCode respects thisValue() from the calling context. It just
would have to be set up. Maybe HostCode did the right thing (we deleted it
after it disappeared from the spec). You're solution is the most pragmatic
one, though. Just guard it with a KJS_PURE_ECMA check, please.
Harri.