Opened 11 years ago
Closed 11 years ago
#12460 closed bug (wontfix)
weird behavior on $.makeArray
Reported by: | simonxu | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | core | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
my code sample is kind of like this
var source = { input : HTMLInputElement, select: HTMLSelectElement, fakeArray : HTMLNodeList } for(var key in source){ var arr = $.makeArray(key) if(arr.length>1){ //do some thing here } }
the result is buggy, $.makeArray do not turn source[select] into an array contains HTMLSelectElement,but an array contains its options. while source[select] do not meet this problem ,maybe because it does not own children and does not own length property? my test is based on chrome 20.0
Change History (3)
comment:1 Changed 11 years ago by
comment:2 Changed 11 years ago by
so my suggestion is if you wanna turn the options into an array, you'd better do it yourself:
$.makeArray(source['select'].children)
hope this will help you,:)
comment:3 Changed 11 years ago by
Component: | unfiled → core |
---|---|
Priority: | undecided → low |
Resolution: | → wontfix |
Status: | new → closed |
Thanks for contributing!
jQuery.makeArray makes no guarantees about what elements are members of the created array. Sure, the options element are not what you'd expect it to return, but this function is simply a convenience utility method that will return array-likes into arrays and nothing fancier.
With that said, I'm going to resolve this as wontfix.
forgive my input errors, i set up a demo page on jsFiddle http://jsfiddle.net/damngoto/ExLbw/