1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-30 23:52:11 +01:00

Dev fix: The API chaining was a little broken if the inner function

returned undefined, null etc.

- The base issue was in the instanceof check which has a priority error,
  it was:
    ! obj instanceof _Api
  which is the same as:
   (! obj) instanceof _Api
  which is rubbish.

  We want:
    ! (obj instanceof _Api)
  but there is of course a wrapper function, so that needs ot be taken
  into account as well. The new logic does just that.
This commit is contained in:
Allan Jardine 2013-11-19 13:54:14 +00:00
parent 8919616833
commit 6740193eed
2 changed files with 10 additions and 9 deletions

View File

@ -1 +1 @@
39706899b20912b09581cc44ef838d469ab4e2fa
c45d7a00a9cb9889d6782276fb21e8c7d2f121e8

View File

@ -6657,14 +6657,15 @@
_Api.extend = function ( scope, obj, ext )
{
if ( ! obj instanceof _Api ) {
// Only extend API instances and static properties of the API
if ( ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
return;
}
var
i, ien,
j, jen,
struct,
struct, inner,
methodScoping = function ( fn, struc ) {
return function () {
var ret = fn.apply( scope, arguments );
@ -6677,14 +6678,14 @@
for ( i=0, ien=ext.length ; i<ien ; i++ ) {
struct = ext[i];
inner = obj[ struct.name ];
// Value
if ( typeof struct.val === 'function' ) {
obj[ struct.name ] = methodScoping( struct.val, struct );
}
else {
obj[ struct.name ] = struct.val;
}
inner = typeof struct.val === 'function' ?
methodScoping( struct.val, struct ) :
struct.val;
inner.__dt_wrapper = true;
// Property extension
_Api.extend( scope, obj[ struct.name ], struct.propExt );