Browse Source

Fix #3029: IE8 does not support getOwnPropertyNames

zhixin 8 years ago
parent
commit
44f3bf5a39
1 changed files with 12 additions and 4 deletions
  1. 12 4
      src/bootstrap-table.js

+ 12 - 4
src/bootstrap-table.js

@@ -182,8 +182,16 @@
 
 
     var compareObjects = function (objectA, objectB, compareLength) {
     var compareObjects = function (objectA, objectB, compareLength) {
         // Create arrays of property names
         // Create arrays of property names
-        var objectAProperties = Object.getOwnPropertyNames(objectA),
-            objectBProperties = Object.getOwnPropertyNames(objectB),
+        var getOwnPropertyNames = Object.getOwnPropertyNames || function (obj) {
+            var arr = [];
+            for (var k in obj) {
+            if (obj.hasOwnProperty(k)) {
+                arr.push(k);
+            }
+            return arr;
+        };
+        var objectAProperties = getOwnPropertyNames(objectA),
+            objectBProperties = getOwnPropertyNames(objectB),
             propName = '';
             propName = '';
 
 
         if (compareLength) {
         if (compareLength) {
@@ -529,7 +537,7 @@
         },
         },
         formatFullscreen: function () {
         formatFullscreen: function () {
             return 'Fullscreen';
             return 'Fullscreen';
-        },            
+        },
         formatColumns: function () {
         formatColumns: function () {
             return 'Columns';
             return 'Columns';
         },
         },
@@ -961,7 +969,7 @@
         } else {
         } else {
             this.options.data = data || this.options.data;
             this.options.data = data || this.options.data;
         }
         }
-        
+
         this.data = this.options.data;
         this.data = this.options.data;
 
 
         if (this.options.sidePagination === 'server') {
         if (this.options.sidePagination === 'server') {