diff --git a/media/src/api/api._selectors.js b/media/src/api/api._selectors.js index 2d31d720..3b4c1fb4 100644 --- a/media/src/api/api._selectors.js +++ b/media/src/api/api._selectors.js @@ -110,7 +110,7 @@ var _selector_first = function ( inst ) if ( inst[i].length > 0 ) { // Assign the first element to the first item in the instance // and truncate the instance and context - inst[0] = inst[i][0]; + inst[0] = inst[i]; inst.length = 1; inst.context = [ inst.context[i] ]; diff --git a/media/src/api/api.base.js b/media/src/api/api.base.js index 08b0a687..cfca40f5 100644 --- a/media/src/api/api.base.js +++ b/media/src/api/api.base.js @@ -618,5 +618,23 @@ _Api.register = function ( name, val ) }; +_Api.registerPlural = function ( pluralName, singularName, val ) { + _Api.register( pluralName, val ); + + _Api.register( singularName, function () { + var ret = val.apply( this, arguments ); + + if ( ret instanceof _Api ) { + return ret.length ? + $.isArray( ret[0] ) ? + new _Api( ret.context, ret[0] ) : // Array results are 'enhanced' + ret[0] : + undefined; + } + return ret; + } ); +}; + + }()); diff --git a/media/src/api/api.cells.js b/media/src/api/api.cells.js index 5e6bf778..7bfba6c4 100644 --- a/media/src/api/api.cells.js +++ b/media/src/api/api.cells.js @@ -35,7 +35,7 @@ _api.register( 'cells()', function ( rowSelector, columnSelector, opts ) { } ); -_api.register( 'cells().nodes()', function () { +_api.registerPlural( 'cells().nodes()', 'cell().nodes()', function () { return this.iterator( 'cell', function ( settings, row, column ) { return settings.aoData[ row ].anCells[ column ]; } ); @@ -49,7 +49,10 @@ _api.register( 'cells().data()', function () { } ); -_api.register( 'cells().invalidate()', function ( src ) { +_api.register( [ + 'cells().invalidate()', + 'cell().invalidate()' +], function ( src ) { var selector = this.selector; // Use the rows method of the instance to perform the invalidation, rather @@ -68,15 +71,6 @@ _api.register( 'cell()', function ( rowSelector, columnSelector, opts ) { } ); -_api.register( 'cell().node()', function () { - var ctx = this.context; - - if ( ctx.length && this.length ) { - return ctx[0].aoData[ this[0].row ].anCells[ this[0].column ]; - } - // undefined -} ); - _api.register( 'cell().data()', function ( data ) { var ctx = this.context; @@ -96,17 +90,6 @@ _api.register( 'cell().data()', function ( data ) { } ); -_api.register( 'cell().invalidate()', function ( src ) { - var ctx = this.context; - - if ( ctx.length && this.length ) { - _fnInvalidateRow( ctx[0], this[0].row, src ); - } - - return this; -} ); - - }()); diff --git a/media/src/api/api.columns.js b/media/src/api/api.columns.js index b1cbd6d7..644a66c9 100644 --- a/media/src/api/api.columns.js +++ b/media/src/api/api.columns.js @@ -89,7 +89,7 @@ _api.register( 'columns()', function ( selector, opts ) { /** * */ -_api.register( 'columns().header()', function ( selector, opts ) { +_api.registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) { return this.iterator( 'column', function ( settings, column ) { return settings.aoColumns[column].nTh; } ); @@ -99,7 +99,7 @@ _api.register( 'columns().header()', function ( selector, opts ) { /** * */ -_api.register( 'columns().data()', function () { +_api.registerPlural( 'columns().data()', 'column().data()', function () { return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) { var a = []; for ( var row=0, ien=rows.length ; row