Side navigation
#5554 closed feature (wontfix)
Opened November 26, 2009 10:04AM UTC
Closed December 05, 2009 03:22AM UTC
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
Attachments (0)
Change History (4)
Changed November 26, 2009 04:22PM UTC by comment:1
Changed November 27, 2009 04:11AM UTC by comment:2
resolution: | → invalid |
---|---|
status: | new → closed |
This seems more appropriate for the jQuery-dev group since it isn't reporting a bug.
Changed November 27, 2009 09:14AM UTC by comment:3
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
Changed December 05, 2009 03:22AM UTC by comment:4
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