From 9ef7f1ad20f4b450ec3bb12a6919a13ac85fa0e4 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Wed, 19 Aug 2015 12:25:28 +0100 Subject: [PATCH] Fix: Compatibility with jQuery 2's `isPlainObject`. API instances were returning as plain objects - This appears to be caused by setting the prototype chain as an object directly. For example: var test = function () {}; test.prototype = {}; $.isPlainObject( new test() ); will return `true` with jQuery 2.1.4 (and `false` for 1.11.3). If an item is added to the prototype object then it will return `false`, although for some reason that wasn't the case with DataTables' API prototype. More investigation required, but for full compatiblity with exisiting jQuery releases, the correct thing to do here is to build on the exisiting prototype, which we can do with `$.extend`. --- .datatables-commit-sync | 2 +- media/js/jquery.dataTables.js | 6 ++++-- media/js/jquery.dataTables.min.js | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.datatables-commit-sync b/.datatables-commit-sync index 3b8bfa66..bef5e639 100644 --- a/.datatables-commit-sync +++ b/.datatables-commit-sync @@ -1 +1 @@ -6f5ada12b6eb080305858981d2a11e8873354d3a +2b8674aa2395b7be7f923e044fdb062e93a8af4e diff --git a/media/js/jquery.dataTables.js b/media/js/jquery.dataTables.js index 0347c7c7..01cdb52b 100644 --- a/media/js/jquery.dataTables.js +++ b/media/js/jquery.dataTables.js @@ -6791,7 +6791,9 @@ DataTable.Api = _Api; - _Api.prototype = /** @lends DataTables.Api */{ + // Don't destroy the existing prototype, just extend it. Required for jQuery 2's + // isPlainObject. + $.extend( _Api.prototype, { any: function () { return this.count() !== 0; @@ -7037,7 +7039,7 @@ unshift: __arrayProto.unshift - }; + } ); _Api.extend = function ( scope, obj, ext ) diff --git a/media/js/jquery.dataTables.min.js b/media/js/jquery.dataTables.min.js index a14000ec..17d5ffe4 100644 --- a/media/js/jquery.dataTables.min.js +++ b/media/js/jquery.dataTables.min.js @@ -93,11 +93,11 @@ b){ka(o,a,b)});if(s.length){var u=function(a,b){return a.getAttribute("data-"+b) o.aaSorting;h=0;for(i=q.length;h").appendTo(this));o.nTHead=i[0];i=r.children("tbody"); 0===i.length&&(i=g("").appendTo(this));o.nTBody=i[0];i=r.children("tfoot");if(0===i.length&&0").appendTo(this);0===i.length||0===i.children().length?r.addClass(j.sNoFooter):0a?new t(b[a],this[a]):null},filter:function(a){var b=[];if(x.filter)b=x.filter.call(this,a,this);else for(var c=0,e=this.length;c