Please help with enumerating functions in window object

I

intrader

I have a need to enumerate all functions in window object in order to
install intercepts. I have problem with the enumeration using the code
in the example
http://jsbin.com/acubo
Note: for now the code lists all elements in the window object.
I expect to see the global function 'fun' listed but I don't see it.
Why?
 
G

Garrett Smith

intrader said:
I have a need to enumerate all functions in window object in order to
install intercepts. I have problem with the enumeration using the code
in the example
http://jsbin.com/acubo
Note: for now the code lists all elements in the window object.
I expect to see the global function 'fun' listed but I don't see it.
Why?
It is a bug of Internet Explorer. Your global property `fun`, declared as:

var fun = function(){
alert('...');
}

should be enumerable. In IE it is not. In IE, the global object is a
Host object. IE also uses a separate Variable object for the global
Variable object. The global Variable object is specified to be the same
as the global object.

That question, and problems related to the answer, comes up here about
every four months or so, dating back to I think I've seen around 2001 or
so (likely earlier). It is explained well enough here:

http://blogs.msdn.com/ericlippert/a...vation-objects-variable-objects-and-this.aspx

A good recent discussion that touched upon this issue, along with other
issues related to IE's global object is [[Delete]]'ing window properties
in IE in JScript.

http://groups.google.com/group/comp...read/thread/22e6b2d147f57ee5/dda4dee3390fa71a

And so after you've read all that, the test question:

How do you make `fun` enumerable in IE?

(It's not that hard, really).
 
J

Jorge


(Fabulous euphemism) "Fabulous Adventures In Coding" (...)
"Brendan Eich, the original creator of JavaScript, was kind enough to
point out at great length that I was WRONG WRONG WRONG" (...)
"It is a bug in JScript, or IE. I'm not sure which yet. I will follow
up with the Sustaining Engineering team and see if we can get this
fixed in a future version of IE. However, I wouldn't hold my breath
waiting if I were you." (May 04, 2005)

(Jan 10, 2010) Bug status: NOT FIXED.
 
I

intrader

(Fabulous euphemism) "Fabulous Adventures In Coding" (...)
"Brendan Eich, the original creator of JavaScript, was kind enough to
point out at great length that I was WRONG WRONG WRONG" (...)
"It is a bug in JScript, or IE.  I'm not sure which yet. I will follow
up with the Sustaining Engineering team and see if we can get this
fixed in a future version of IE. However, I wouldn't hold my breath
waiting if I were you." (May 04, 2005)

(Jan 10, 2010) Bug status: NOT FIXED.

I appreciate all your answers. The problem remains that I wish to
install intercepts in all functions without modifying the source code;
I am aware that to store the function reference as a property of the
window object ("created_via_property_assignment" as explained by
kangax in http://groups.google.com/group/comp...read/thread/22e6b2d147f57ee5/dda4dee3390fa71a)
makes the 'item' enumerable.
The intercepts are for debugging, profiling, and other functions. I am
aware of the Web Developer Tools in IE8 (that provides a profiler).
I apologize for not finding this issue reported before.
 
G

Garrett Smith

kangax said:
[...]

Apparently google groups ate part of the title, turning "[[Delete]]'ing"
into cryptic "]'ing" :)
Maybe Google wants us to read that cryptic "]" as a curse word symbol,
to the effect "effing properites in IE".
 
I

intrader

kangax said:
[...]

Apparently google groups ate part of the title, turning "[[Delete]]'ing"
into cryptic "]'ing" :)

Maybe Google wants us to read that cryptic "]" as a curse word symbol,
to the effect "effing properites in IE".

I don't quite follow the delete problem with google.

I don't want to use host access in order to enumerate in IE. However,
the application framework has installed an Active pluggin to help with
caching (not my design), and I think that I can install the intercepts
in the source code.

If you all know of another way to enumerate global functions, I would
appreciate greatly.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top