Variable override
Harri Porten
porten at kde.org
Sat Apr 16 21:25:41 CEST 2005
Hi again,
I just looked at the following code in JavaScriptCore'S
VarDeclNode::evaluate() function:
// already declared? - check with getDirect so you can override
// built-in properties of the global object with var declarations.
if ( variable.imp()->getDirect(ident) )
return Value();
I am aware of the difference between hasProperty() (what KJS uses) and
getDirect(). But I don't quite understand the difference this change makes
here. After all VarDeclNode::processVarDecls() uses hasProperty() and will
"put" an Undefined() value into the variable object. In fact I wonder why
both versions of the libraries do have to make the check twice at all.
I've tried to come up with a test case demonstrating a difference in
behavior but I failed. I tried
var NaN;
document.write(NaN);
which returns the expected value of "undefined" in KJS. Could anyone
explain the purpose of above change (except speed differences) or provide
some sample JS code where the change makes a difference?
Thank you,
Harri.
More information about the Khtml-devel
mailing list