Opened 14 years ago
Closed 14 years ago
#5554 closed feature (wontfix)
length expando overwrite
Reported by: | dbjdbj | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.4 |
Component: | core | Version: | 1.3.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
We know that length expando is overwritten by certain browsers, in certain situations. Maybe a new utility function should be added to the core.js ?
safeLength : function ( obj ) { if ( jQuery.isArray(obj)) return obj.length ; var j = 0; while ( obj[j++] ) ; return j-1 ; }
This could/should be used from merge(), grep(), map() and each()
--DBJ
Change History (4)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
This seems more appropriate for the jQuery-dev group since it isn't reporting a bug.
comment:3 Changed 14 years ago by
Resolution: | invalid |
---|---|
Status: | closed → reopened |
I admit I "made it" into bug to gain attention. Please look into my fork on GITHUB (user: DBJDBJ ) I managed to streamline each() using the above and to streamline merge(), grep(), makeArray() to use each(). I have done testing. This needs to be tested/seen by someone from the core team. Looks ok and obvious, but is a non-trivial change in the core.
Thanks: Dusan
comment:4 Changed 14 years ago by
Component: | unfilled → core |
---|---|
Resolution: | → wontfix |
Status: | reopened → closed |
Type: | bug → feature |
This isn't really something that we need in core. We just do looping in a particular way to avoid the problem outright.
I am thinking ... maybe I have jumped on this one too eraly? I think that each() will solve safely "length expando overwrite" because it does objects (ie non-arrays) with for/in loop anyway? that is it does not use length. So maybe each() as it is, does the job? the solution is to make grep(), merge(), map() etc, to use each().
safeLength() might stay, but I do not see where it could be used inside jQuery ? There must be some use for it ?
--DBJ