Closed coolaj86 closed 12 years ago
there's a general problem for all things operating on this[0]
and .val()
is just one of them. i'll more than likely create a patch for the entire batch
I take it back! I love this feature.
I guess I was just in a jQuery-drunken mindset when I filed this issue.
This has saved me so many hours of debugging because it's immediately obvious when I've misspelled something, etc.
Please don't fix!
@ded, what's your opinion on this? I'm used to hard-fail, Prototype-style but am really beginning to like silent-fail and would prefer that methods don't throw just because you haven't selected anything. Certainly makes unit testing a whole lot easier--you don't need to supply whole chunks of DOM just to test small things.
the hard fail shouldn't be in the library. i think if you deliberately (or accidentally) selected nothing, we should "do action on nothing" — not break. similar to regular JavaScript iterators:
// oops, i accidentally my array
[].map(function () {
// never gets run
})
therefore, we really need to go in and check the existence of this[0]
before taking action on undefined
this can be closed now that #48 is in and cleans this whole area up
Sorry, that really needed some context:
I suppose this could be considered a feature, but there are also instances where sometimes an element exists and sometimes it doesn't.