This is an interesting topic and you make a good point. I suppose the
question is, are we going to use prototype or not? When I originally
suggested using namespaces I didn't mean to extend the object as well
as use a namespace. I personally don't think it is a good idea for a
library to 'pollute' the global object ... especially if we want to be
compatible with other libraries and be future proof.

I still think that using a namespace and providing a short cut like $A
is the best way to handle this, instead of extending the element or
prototype. I think we could even get chaining to work properly if we
really wanted too. We could also probably provide a way to extend the
prototype if users really wanted it.

--
Brandon Aaron


On 11/15/06, "Jörn Zaefferer" <[EMAIL PROTECTED]> wrote:
> > > Won't that cause the same problems when used with for-in loops?
> >
> > Yes, but only on the object itself and for/in shouldn't be used for
> > arrays. I don't believe there should be a conflict.
>
> My words for not using for-in. But if the problem can occur on the object 
> again, I don't really see the win here.
>
> While I can understand that there are libraries using for-in loops on arrays, 
> I see no reason to not extent the String prototype. It saves you a lot of 
> trouble and is pretty and clean.
>
> I think adding this:
> String.prototype.trim = function() { ... }
>
> Is much cleaner then $.trim(...)
>
> Iterating over Strings doesn't make much sense, so there is no problem with 
> for-in loops.
>
> While we are at it: jQuery doesn't promote usage of "bad code". Take the 
> shadowed XMLHttpRequest: If a library uses that for browser checks, it will 
> give a wrong result. It may not occur as often as for-in loops on arrays, but 
> basically it's the same problem.
>
> I have implemented some extensions for String here: 
> http://fuzz.bassistance.de/sandbox/string.js
> It consists of trim, camelize, startsWith (supports offset), endsWith and 
> some isXXX checks like isAlpha, isUpper, isDigit.
>
> --
> Jörn Zaefferer
>
> http://bassistance.de
>
> --
> Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
> Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to