You can still write a simple plugin:

jQuery.fn.fail=function(){ return this.length ? this : null; }

Now $('#non-existing-id').fail().toggle() will fail,
but will work if it's not empty.

Consider this for example:
$('#non-existing-id').add('.anotherClass');
if it failed you cannot add other elements to the empty set
and you can't even write a plugin like this one above.

On Nov 5, 10:08 am, brian <[EMAIL PROTECTED]> wrote:
> > It's not a failure to run a query and find nothing - that's a
> > perfectly valid use case.
>
> I understand where you are coming from on the querying side, but
> shouldn't calling a method on an empty object fail?  How can I fade
> in...nothing?
>
> I'm going to still think of this as a huge design flaw.
>
> There needs to be a way to specify that it should fail on empty
> results.  /s for strict or whatever.
>
> This post is for 1) bitching purposes and 2) indexing purposes so that
> future searchers find definitive proof that jquery fails silently and
> that this is not considered a bug, despite obvious appearances.

Reply via email to