To recap if I may ?

The safer and slower approach is to use hasOwnProperty() in for .. in
loops
Even that is not 100% fool-proof (I like this term 'fool-proof' ;o) ,
but improves situation considerably. Last and desperate "hand grenade"
is :

for ( var j in Object.prototype ) delete Object.prototype[j] ;

(or whatever "awesome" trick code one wants to use ...)

So the best way forward might be (as suggested) already
jQuery.safe_and_slow.1.3.3.js for people who need to fight it out with
legacy code before being able to revert to jquery.1.3.3.js ...

So the question is : "oooza gona save us..?"

-- DBJ

On Apr 28, 11:38 am, Andrea Giammarchi <[email protected]>
wrote:
> ehr ... JSON convention does not convert functions in any case ...
>
> On Tue, Apr 28, 2009 at 11:27 AM, DBJDBJ <[email protected]> wrote:
>
> > IE8 JSON has no problems with user extended Object.prototype
>
> > Object.prototype.any_method = function () { return true; }
>
> > JSON.stringify( Object() )
> > /*{}*/
> > JSON.stringify( new Object() )
> > /*{}*/
> > JSON.stringify( Object.prototype )
> > /*{}*/
> > var o = new Object(); o.any_method()
> > /*true*/
>
> > This is an example of  the legal and standard way to deal with the
> > issue.
> > This is how jQuery should behave.
>
> > -- DBJ
>
> > On Apr 28, 7:52 am, Andrea Giammarchi <[email protected]>
> > wrote:
> > > As alternative, let's move the problem to other libraries via single
> > line:
>
> > > (function(p){for(var k in p)delete p[k];})(Object.prototype);
>
> > > and then use Sizzle, jQuery, or whatever you need with a for in loop :D
>
> > > On Mon, Apr 27, 2009 at 7:00 PM, Ricardo <[email protected]> wrote:
>
> > > > I also like this approach because apparently there's no way to protect
> > > > the loops without downgrading performance or relying on a length
> > > > property. It depends on the way it's presented, I doubt a novice would
> > > > choose to download a version labeled "Object.prototype safe" if he
> > > > doesn't know what it means. And if he does, no harm is done except for
> > > > slightly worse performance. Might aswell do the opposite, an "unsafe"
> > > > version for developers who have full control of their environment.
>
> > > > On Apr 26, 2:59 pm, ajpiano <[email protected]> wrote:
> > > > > I tend to think an alternate build being available from the website
> > > > > would tend to be confusing to the average consumer, especially given
> > > > > the fact that Object.prototype "insurance" is a goal for an upcoming
> > > > > release (so I've heard...)  It won't be very long before Google grabs
> > > > > this thread and exposes the techniques demonstrated to anyone who
> > > > > might be after a temporary fix.
>
> > > > > On Apr 24, 4:43 pm, Daniel Friesen <[email protected]>
> > wrote:
>
> > > > > > I think I like the idea of an alternate jQuery download.
>
> > > > > > for ( var i in hash ) /*...@cc loopsafe; if( hash.hasOwnProperty( i 
> > > > > > )
> > ) */
> > > > > >   attr[i] = hash[i];
>
> > > > > > Standard jQuery build would contain:
> > > > > > for ( var i in hash )
> > > > > >   attr[i] = hash[i];
>
> > > > > > While a special jquery.loopsafe.js build would contain:
> > > > > > for ( var i in hash ) if( hash.hasOwnProperty( i ) )
> > > > > >   attr[i] = hash[i];
>
> > > > > > The result being that there is an alternate build of jQuery for
> > people
> > > > > > that currently need to deal with legacy code which extends
> > > > Object.prototype;
> > > > > > I find this to be a fair solution. It gives an option to those who
> > want
> > > > > > to use jQuery in an environment which is already hostile due to
> > legacy
> > > > > > code they slowly want to remove.
> > > > > > But it also caters to the larger group of us that know not to touch
> > > > > > Object.prototype and don't care for the slowdown.
>
> > > > > > ~Daniel Friesen (Dantman, Nadir-Seen-Fire)
>
> > > > > > Balazs Endresz wrote:
> > > > > > > Well, if someone really needs a quick *intermediate* solution it
> > can
> > > > > > > be done by inserting checks with search and replace. I didn't
> > think
> > > > it
> > > > > > > through properly at all but it seems to work if you execute these
> > in
> > > > > > > order (except for the loop around line 3757, where a semicolon
> > should
> > > > > > > be removed after `add( j, this );`). Don't try it on any other
> > > > script,
> > > > > > > this is only intended for the current (1.3.2) release!
>
> > > > > > > loop with braces:
> > > > > > > (for \( (var )?([^\n]+) in ([^\n]+)\) {)
> > > > > > > $1 if ( !$4.hasOwnProperty( $3 ) ){ continue }
>
> > > > > > > single line loop without braces:
> > > > > > > (for \( (var )?([^\n{]+) in ([^\n{]+)\) )(?!{)([^;]+;)
> > > > > > > $1{ if ( !$4.hasOwnProperty( $3 ) ){ continue } \n $5 }
>
> > > > > > > multiline loop without braces:
> > > > > > > (for \( (var )?([^\n{]+) in ([^\n{]+)\))[^ ]
> > > > > > > $1 { if ( !$4.hasOwnProperty( $3 ) ){ continue } \n $5 }
>
> > > > > > > Here's a modified version:http://pastebin.com/m731b1dff
>
> > > > > > > On Apr 24, 1:13 pm, DBJDBJ <[email protected]> wrote:
>
> > > > > > >> we all then nicely agree, no flames here ;o)
>
> > > > > > >> still we have no solution to Captain P. and other jQuery well
> > > > wishers
> > > > > > >> who have inherited legacy javascript apps and who want to
> > refactor
> > > > > > >> them using jQ only.
> > > > > > >> while having to keep the legacy app running ...
>
> > > > > > >> -- DBJ
>
> > > > > > >> On Apr 23, 11:06 am, Andrea Giammarchi <
> > [email protected]
>
> > > > > > >> wrote:
>
> > > > > > >>> @DBJ I know what you mean and I talked about this ages ago in
> > my 5
> > > > cents
> > > > > > >>> about javascript prototypal inheritance ...
>
> > > > > > >>> Summary, respecting Mozilla convention for other Array cases
> > > > (forEach,
> > > > > > >>> filter, some, map, etc):
>
> > > > > > >>> Object.prototype.forIn = function(callback, self){
> > > > > > >>>     for(var key in this){
> > > > > > >>>         if(this.hasOwnProperty(key))
> > > > > > >>>             callback.call(self, this[key], key, this);
> > > > > > >>>     };
>
> > > > > > >>> };
>
> > > > > > >>> // simple test case
> > > > > > >>> Object.prototype.a = 1;
> > > > > > >>> ({b:2}).forIn(function(value, key, object){
> > > > > > >>>     alert(key);
>
> > > > > > >>> });
>
> > > > > > >>> Above forIn prototype could be the "de-facto" standard for
> > every
> > > > library
> > > > > > >>> then we'll find some clever guru that will overwrite that
> > prototype
> > > > causing
> > > > > > >>> "disasters" ... the same could be relying the hasOwnProperty
> > method
> > > > ... it
> > > > > > >>> could be redefined from other silly developers.
>
> > > > > > >>> As summary, due to the dynamic nature of the language,
> > > > Object.prototype is
> > > > > > >>> untouchable but if a library touches it we all should "sign" a
> > > > deal:
> > > > > > >>> hasOwnProperty has to be the native one so we can all use that
> > > > method for
> > > > > > >>> each "for in" call (slowing down consistently every browser ...
> > so
> > > > again, do
> > > > > > >>> not touch the Object.prototype or you gonna have troubles)
>
> > > > > > >>> Regards
>
> > > > > > >>> On Thu, Apr 23, 2009 at 10:26 AM, DBJDBJ <[email protected]>
> > wrote:
>
> > > > > > >>>> @Andrea
>
> > > > > > >>>> Captains text is the best example why you are not supposed to
> > say
> > > > :
> > > > > > >>>> " ...  for people that use obtrusive code that changes the
> > > > > > >>>> Object.prototype..."
>
> > > > > > >>>> Faced with a javascript royal mess he inherited, Captain P.
> > > >  trusted
> > > > > > >>>> that jQuery is the way to go. But now his trust is somewhat
> > less
> > > > > > >>>> prominent...
>
> > > > > > >>>> Me or you or Captain P. we surely will not extend
> > > > Object.prototype,
> > > > > > >>>> but still we need jQuery that will work in the presence of a
> > code
> > > > that
> > > > > > >>>> does this. We do not need to be talled that Object.prototype
> > > > should
> > > > > > >>>> never be extended.
>
> > > > > > >>>> So jQ team, just go ahead and do it ;o) ... There are tons of
> > > > legacy
> > > > > > >>>> javascript out there with Object.prototype abused
> > comprehensively.
> > > > > > >>>> Right now none of it can be replaced with jjQuery.
>
> > > > > > >>>> --DBJ
>
> > > > > > >>>> On Apr 22, 2:30 pm, Andrea Giammarchi <
> > > > [email protected]>
> > > > > > >>>> wrote:
>
> > > > > > >>>>> I did not know a native hasOwnProperty method as boolean
> > > > condition could
> > > > > > >>>>> cause so many troubles but I simply replied to Captain
> > Palapa. It
> > > > was not
>
> > > > > > >>>> a
>
> > > > > > >>>>> suggestion for Sizzle, just a quick fix for people that use
> > > > obtrusive
>
> > > > > > >>>> code
>
> > > > > > >>>>> that changes the Object.prototype.
> > > > > > >>>>> But, obviously, if Sizzle uses for in everywhere, well ...
> > that
> > > > is just
>
> > > > > > >>>> the
>
> > > > > > >>>>> top of the iceberg :-)
>
> > > > > > >>>>> Regards
>
> > > > > > >>>>> On Wed, Apr 22, 2009 at 2:14 PM, DBJDBJ <[email protected]>
> > > > wrote:
>
> > > > > > >>>>>> I tough of that, seemingly obvious ... but I think it has
> > not
> > > > > > >>>>>> worketh ...
>
> > > > > > >>>>>> Also this will require a non trivial jQ+Sizzle refactoring.
> > Lot
> > > > of
> > > > > > >>>>>> testing, etc ... Me thinks ?
>
> > > > > > >>>>>> -- DBJ
>
> > > > > > >>>>>> On Apr 22, 9:01 am, Andrea Giammarchi <
> > > > [email protected]>
> > > > > > >>>>>> wrote:
>
> > > > > > >>>>>>> Have you tried this already?
>
> > > > > > >>>>>>> 1585:                    if
> > (Expr.filter.hasOwnProperty(type)
> > > > &&
>
> > > > > > >>>> (match =
>
> > > > > > >>>>>>> Expr.match[type].exec(expr)) !=
>
> > > > > > >>>>>>>>>> null) {
>
> > > > > > >>>>>>> Regards
>
> > > > > > >>>>>>> On Tue, Apr 21, 2009 at 10:02 PM, CaptainPalapa <
>
> > > > > > >>>> [email protected]
>
> > > > > > >>>>>>> wrote:
>
> > > > > > >>>>>>>> Are there any solutions to this issue yet?  We're
> > reworking
> > > > our
>
> > > > > > >>>> entire
>
> > > > > > >>>>>>>> framework that (prior to my arrival) was a mess of
> > Prototype,
> > > > > > >>>>>>>> ColdFusion CFAjax stuff, Spry, you name it.  We're slowly
> > > > replacing
> > > > > > >>>>>>>> other code with jQuery calls, but it's not going to be an
> > > > overnight
> > > > > > >>>>>>>> process...and we still have to keep the existing site
> > running.
> > > >  The
> > > > > > >>>>>>>> noConflict() doesn't completely solve all our issues, but
> > sure
> > > > made
>
> > > > > > >>>> a
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to