From 5d798c28a6db88c0a5e974c1d34bef4f3d2aa670 Mon Sep 17 00:00:00 2001 From: "Frank.Qiu" Date: Mon, 5 Mar 2018 10:34:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=AE=E5=89=8D=E5=8F=91=E7=8E=B0=E7=9A=84ie?= =?UTF-8?q?8=E4=B8=8B=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/fineui.js | 44 +++++++++++++++++++++++++++++++++++++++++- dist/polyfill.js | 44 +++++++++++++++++++++++++++++++++++++++++- src/polyfill/lodash.js | 43 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 src/polyfill/lodash.js diff --git a/dist/fineui.js b/dist/fineui.js index 95b456d4a..c2a468b3d 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -154,7 +154,49 @@ window.localStorage || (window.localStorage = { clear: function () { this.items = {}; } -});if (typeof Set !== "undefined" && Set.toString().match(/native code/)) { +}); +if (!Object.keys) { + Object.keys = function(o) { + if (o !== Object(o)) { + throw new TypeError('Object.keys called on a non-object'); + } + // fix的问题 + var falsy; + var skipArray = { + __ob__: falsy, + $accessors: falsy, + $vbthis: falsy, + $vbsetter: falsy + }; + var k = [], p; + for (p in o) { + if (!(p in skipArray)) { + if (Object.prototype.hasOwnProperty.call(o, p)) { + k.push(p); + } + } + } + return k; + }; +} + +if (!Array.isArray) { + Array.isArray = function(arg) { + return Object.prototype.toString.call(arg) === '[object Array]'; + }; +} + +// https://stackoverflow.com/questions/10919915/ie8-getprototypeof-method +if (typeof Object.getPrototypeOf !== "function") { + Object.getPrototypeOf = "".__proto__ === String.prototype + ? function (object) { + return object.__proto__; + } + : function (object) { + // May break if the constructor has been tampered with + return object.constructor.prototype; + }; +}if (typeof Set !== "undefined" && Set.toString().match(/native code/)) { } else { Set = function () { diff --git a/dist/polyfill.js b/dist/polyfill.js index 052cfb574..47f771c9d 100644 --- a/dist/polyfill.js +++ b/dist/polyfill.js @@ -154,7 +154,49 @@ window.localStorage || (window.localStorage = { clear: function () { this.items = {}; } -});if (typeof Set !== "undefined" && Set.toString().match(/native code/)) { +}); +if (!Object.keys) { + Object.keys = function(o) { + if (o !== Object(o)) { + throw new TypeError('Object.keys called on a non-object'); + } + // fix的问题 + var falsy; + var skipArray = { + __ob__: falsy, + $accessors: falsy, + $vbthis: falsy, + $vbsetter: falsy + }; + var k = [], p; + for (p in o) { + if (!(p in skipArray)) { + if (Object.prototype.hasOwnProperty.call(o, p)) { + k.push(p); + } + } + } + return k; + }; +} + +if (!Array.isArray) { + Array.isArray = function(arg) { + return Object.prototype.toString.call(arg) === '[object Array]'; + }; +} + +// https://stackoverflow.com/questions/10919915/ie8-getprototypeof-method +if (typeof Object.getPrototypeOf !== "function") { + Object.getPrototypeOf = "".__proto__ === String.prototype + ? function (object) { + return object.__proto__; + } + : function (object) { + // May break if the constructor has been tampered with + return object.constructor.prototype; + }; +}if (typeof Set !== "undefined" && Set.toString().match(/native code/)) { } else { Set = function () { diff --git a/src/polyfill/lodash.js b/src/polyfill/lodash.js new file mode 100644 index 000000000..e01c30f80 --- /dev/null +++ b/src/polyfill/lodash.js @@ -0,0 +1,43 @@ + +if (!Object.keys) { + Object.keys = function(o) { + if (o !== Object(o)) { + throw new TypeError('Object.keys called on a non-object'); + } + // fix的问题 + var falsy; + var skipArray = { + __ob__: falsy, + $accessors: falsy, + $vbthis: falsy, + $vbsetter: falsy + }; + var k = [], p; + for (p in o) { + if (!(p in skipArray)) { + if (Object.prototype.hasOwnProperty.call(o, p)) { + k.push(p); + } + } + } + return k; + }; +} + +if (!Array.isArray) { + Array.isArray = function(arg) { + return Object.prototype.toString.call(arg) === '[object Array]'; + }; +} + +// https://stackoverflow.com/questions/10919915/ie8-getprototypeof-method +if (typeof Object.getPrototypeOf !== "function") { + Object.getPrototypeOf = "".__proto__ === String.prototype + ? function (object) { + return object.__proto__; + } + : function (object) { + // May break if the constructor has been tampered with + return object.constructor.prototype; + }; +} \ No newline at end of file