} );
QUnit.test( "Labels", function( assert ) {
- assert.expect( 2 );
+ assert.expect( 3 );
var expected = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ];
var dom = $( "#labels-fragment" );
// Detach the dom to test on a fragment
dom.detach();
testLabels( "document fragments" );
+
+ assert.equal( $().labels().length, 0, "No element" );
} );
( function() {
return $.fn.labels = function() {
var ancestor, selector, id, labels, ancestors;
+ if ( !this.length ) {
+ return this.pushStack( [] );
+ }
+
// Check control.labels first
if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
return this.pushStack( this[ 0 ].labels );