mirror of
https://github.com/DataTables/DataTables.git
synced 2025-01-18 11:52:11 +01:00
Internal: Small enhancement to registerPlural to correctly deal with
same instance returns.
This commit is contained in:
parent
f5286dc130
commit
0ab8eb7ed0
@ -624,13 +624,21 @@ _Api.registerPlural = function ( pluralName, singularName, val ) {
|
||||
_Api.register( singularName, function () {
|
||||
var ret = val.apply( this, arguments );
|
||||
|
||||
if ( ret instanceof _Api ) {
|
||||
if ( ret === this ) {
|
||||
// Returned item is the API instance that was passed in, return it
|
||||
return this;
|
||||
}
|
||||
else if ( ret instanceof _Api ) {
|
||||
// New API instance returned, want the value from the first item
|
||||
// in the returned array for the singular result.
|
||||
return ret.length ?
|
||||
$.isArray( ret[0] ) ?
|
||||
new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
|
||||
ret[0] :
|
||||
undefined;
|
||||
}
|
||||
|
||||
// Non-API return - just fire it back
|
||||
return ret;
|
||||
} );
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user