Bug 16857 - defining existing variable with var statement dumps original
Summary: defining existing variable with var statement dumps original
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-12 15:33 PST by Jelmer van der Linde
Modified: 2008-01-12 16:35 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jelmer van der Linde 2008-01-12 15:33:03 PST
When defining a variable with a var-statement in the global scope, and window[varname] already exists, window[varname] is deleted before the code block is actually executed. Example with window.Element: http://mirror.ikhoefgeen.nl/mootools/711/element_test.html

The following code in in nightly build 29385:
> document.write(typeof window.Element);
> var Element = 'foobar';
> document.write(typeof window.Element);
results in
> undefined
> string

where omitting the var statement
> document.write(typeof window.Element)
results in the expected
> object

Other browsers, for example Firefox 2.0.0.2 and Opera 9.25 produce:
> function
> string


Tested with Webkit Nightly build 29385, Mac OS X 10.5.1 Intel
Comment 1 David Kilzer (:ddkilzer) 2008-01-12 16:17:59 PST
Please test again with a WebKit nightly build of r29428 or later.  See Bug 16644.

Comment 2 Jelmer van der Linde 2008-01-12 16:35:06 PST
Works like a charm :-)

Testcase returns 'object' as expected.