prototype.js functions in an array?

E

Emanuele D'Arrigo

Hi everybody,

if you have a look to this page

http://www.manu3d.com/jsTests/test.html

you'll find a red rectangle. If you click on the rectangle
the content of an "allegedly" empty array is printed out.
As you will see, it isn't exactly empty.

http://www.manu3d.com/jsTests/test.js

holds the js code. It seems to me that this problem
is related to prototype.js as the array shows as
correctly empty if that file isn't sourced.
But can anybody explain me why is this happening?

Thank you.

Manu
 
R

Randy Webb

Emanuele D'Arrigo said the following on 10/22/2006 6:37 PM:
Hi everybody,

if you have a look to this page

http://www.manu3d.com/jsTests/test.html

you'll find a red rectangle. If you click on the rectangle
the content of an "allegedly" empty array is printed out.
As you will see, it isn't exactly empty.

http://www.manu3d.com/jsTests/test.js

holds the js code. It seems to me that this problem
is related to prototype.js as the array shows as
correctly empty if that file isn't sourced.
But can anybody explain me why is this happening?

Because prototype extends the Array object (often un-necessarily) and
you are seeing the consequences of that. Another reason why prototype.js
is frowned upon in this group.
 
P

Peter Michaux

Randy said:
Emanuele D'Arrigo said the following on 10/22/2006 6:37 PM:

Because prototype extends the Array object (often un-necessarily) and
you are seeing the consequences of that. Another reason why prototype.js
is frowned upon in this group.

It looks like the two newest versions of Prototype don't extend Object
prototype anymore. However it doesn't look like there are any plans to
stop extending the Array prototype.
 
R

RobG

Peter Michaux wrote:
[...]
It looks like the two newest versions of Prototype don't extend Object
prototype anymore. However it doesn't look like there are any plans to
stop extending the Array prototype.

Have they fixed the case where $() returns named elements instead of
id'd ones in IE?

e.g. given valid HTML:

<div>
<input name="foo" value="foo input">
</div>
<div id="foo">foo div<br>
<button onclick="alert($('foo').tagName);">Call $('foo')</button>
</div>

What should the alert show: the div, the input, both or an error?
 
R

Randy Webb

Peter Michaux said the following on 10/22/2006 10:34 PM:
Randy Webb wrote:


It looks like the two newest versions of Prototype don't extend Object
prototype anymore. However it doesn't look like there are any plans to
stop extending the Array prototype.

Did you notice that I said nothing about Object's though? <g>
 
E

Emanuele D'Arrigo

Randy said:
Because prototype extends the Array object (often un-necessarily) and
you are seeing the consequences of that. Another reason why prototype.js
is frowned upon in this group.

Thanks for the confirmation Randy, and everybody else who answered.

Manu
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top