Hi,
Prototype's api docs (http://www.prototypejs.org/api/element/
getElementsByClassName) state that the method returns an array,
normally.
They also say As of Prototype 1.6, document.getElementsByClassName
has been deprecated since native implementations return a NodeList
rather than an Array. Please use $$ or Element#select instead.
When two methods with the same name are available, one in prototype
and one from the browser, am I able to determine which method is used?
That would probably be tricky, but basically, you shouldn't have to.
The Core team (now) try to avoid choosing signatures that will be
similar-but-different in a future native implementation (where
possible, obviously!) and as with getElementsByClassName will
typically obsolete (deprecate) where that hasn't been possible,
documenting the replacement.
HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available
On Apr 2, 8:57 am, basti bastian.friedr...@am-soft.de wrote:
Good morning,
I wanted to use the method getElementsByClassName by prototype to
retrieve an array of objects. Using my Firefox 3.0.7 on Windows XP
alert told me that the returned value by this method is a Nodelist,
which I couldn't iterate using prototypes each-method for arrays.
Prototype's api docs (http://www.prototypejs.org/api/element/
getElementsByClassName) state that the method returns an array,
normally. Using google I found this
link:https://developer.mozilla.org/en/DOM/document.getElementsByClassName
It seems that getElementsByClassName is implemented by Firefox and
prototyp and that prototype doesn't override the native
implementation.
When two methods with the same name are available, one in prototype
and one from the browser, am I able to determine which method is used?
I understand that prototype doesn't want to override native
implementations of methods to not break browser compability but in
this case where I use prototype to achieve that my scripts run the
same way on almost every browser Firefox's impolementation of the
prototype function is breaking my script because of incompatible
returned data types by the two implementations of the method.
I couldn't find any suggestions on how to deal with those situations.
Is the only way to check for the needed data types on method returns
and work around the fact that methods may be implemented in the
browser nativley using different data types for return values? This
would be a lot of work to do for every common function provided by
prototype which could be implemented natively, too.
bye
basti
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Prototype script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~--~~~~--~~--~--~---