diff --git a/source/Ox/js/Fallback.js b/source/Ox/js/Polyfill.js similarity index 75% rename from source/Ox/js/Fallback.js rename to source/Ox/js/Polyfill.js index 0fb929a0..1986f49c 100644 --- a/source/Ox/js/Fallback.js +++ b/source/Ox/js/Polyfill.js @@ -1,10 +1,10 @@ 'use strict'; -Ox.fallback = {}; +Ox.polyfill = {}; (function(global) { /*@ - Ox.fallback.bind see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind + Ox.polyfill.bind see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind > Ox.test.array [[1, 0], [2, 1], [3, 2]] @*/ -Ox.fallback.forEach = function(iterator, that) { +Ox.polyfill.forEach = function(iterator, that) { if (this === void 0 || this === null || typeof iterator !== 'function') { throw new TypeError(); } @@ -103,13 +103,13 @@ Ox.fallback.forEach = function(iterator, that) { }; /*@ -Ox.fallback.indexOf see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf - > Ox.fallback.indexOf.call([1, 2, 3, 2, 1], 2) +Ox.polyfill.indexOf see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf + > Ox.polyfill.indexOf.call([1, 2, 3, 2, 1], 2) 1 - > Ox.fallback.indexOf.call([1, 2, 3, 2, 1], 4) + > Ox.polyfill.indexOf.call([1, 2, 3, 2, 1], 4) -1 @*/ -Ox.fallback.indexOf = function(value) { +Ox.polyfill.indexOf = function(value) { if (this === void 0 || this === null) { throw new TypeError(); } @@ -124,28 +124,28 @@ Ox.fallback.indexOf = function(value) { }; /*@ -Ox.fallback.isArray see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray - > Ox.fallback.isArray([]) +Ox.polyfill.isArray see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray + > Ox.polyfill.isArray([]) true - > Ox.fallback.isArray((function() { return arguments; }())) + > Ox.polyfill.isArray((function() { return arguments; }())) false - > Ox.fallback.isArray({0: 0, length: 1}) + > Ox.polyfill.isArray({0: 0, length: 1}) false @*/ -Ox.fallback.isArray = function(value) { +Ox.polyfill.isArray = function(value) { return Object.prototype.toString.call(value) == '[object Array]'; }; /*@ -Ox.fallback.JSON see https://github.com/douglascrockford/JSON-js - > Ox.fallback.JSON.parse('{"a": [1, 2], "b": [3, 4]}') +Ox.polyfill.JSON see https://github.com/douglascrockford/JSON-js + > Ox.polyfill.JSON.parse('{"a": [1, 2], "b": [3, 4]}') {a: [1, 2], b: [3, 4]} - > Ox.fallback.JSON.stringify([(function(){ return arguments; }()), false, null, 0, Infinity, NaN, / /, void 0]) + > Ox.polyfill.JSON.stringify([(function(){ return arguments; }()), false, null, 0, Infinity, NaN, / /, void 0]) '[{},false,null,0,null,null,{},null]' - > Ox.fallback.JSON.stringify(new Date()).length + > Ox.polyfill.JSON.stringify(new Date()).length 24 @*/ -Ox.fallback.JSON = (function() { +Ox.polyfill.JSON = (function() { var replace = { '"': '\\"', '\b': '\\b', @@ -198,11 +198,11 @@ Ox.fallback.JSON = (function() { }()); /*@ -Ox.fallback.keys see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys - > Ox.fallback.keys({a: 1, b: 2, c: 3}) +Ox.polyfill.keys see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys + > Ox.polyfill.keys({a: 1, b: 2, c: 3}) ['a', 'b', 'c'] @*/ -Ox.fallback.keys = function(object) { +Ox.polyfill.keys = function(object) { if (object !== Object(object)) { throw new TypeError(); } @@ -216,13 +216,13 @@ Ox.fallback.keys = function(object) { }; /*@ -Ox.fallback.lastIndexOf see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf - > Ox.fallback.lastIndexOf.call([1, 2, 3, 2, 1], 2) +Ox.polyfill.lastIndexOf see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf + > Ox.polyfill.lastIndexOf.call([1, 2, 3, 2, 1], 2) 3 - > Ox.fallback.lastIndexOf.call([1, 2, 3, 2, 1], 4) + > Ox.polyfill.lastIndexOf.call([1, 2, 3, 2, 1], 4) -1 @*/ -Ox.fallback.lastIndexOf = function(value) { +Ox.polyfill.lastIndexOf = function(value) { if (this === void 0 || this === null) { throw new TypeError(); } @@ -237,11 +237,11 @@ Ox.fallback.lastIndexOf = function(value) { }; /*@ -Ox.fallback.map see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map - > Ox.fallback.map.call([2, 1, 0], function(v, i) { return v == i; }) +Ox.polyfill.map see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map + > Ox.polyfill.map.call([2, 1, 0], function(v, i) { return v == i; }) [false, true, false] @*/ -Ox.fallback.map = function(iterator, that) { +Ox.polyfill.map = function(iterator, that) { if (this === void 0 || this === null || typeof iterator !== 'function') { throw new TypeError(); } @@ -256,11 +256,11 @@ Ox.fallback.map = function(iterator, that) { }; /*@ -Ox.fallback.reduce see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce - > Ox.fallback.reduce.call([1, 2, 3], function(p, c, i) { return p + c + i; }, 1) +Ox.polyfill.reduce see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce + > Ox.polyfill.reduce.call([1, 2, 3], function(p, c, i) { return p + c + i; }, 1) 10 @*/ -Ox.fallback.reduce = function(iterator, ret) { +Ox.polyfill.reduce = function(iterator, ret) { if (this === void 0 || this === null || typeof iterator !== 'function') { throw new TypeError(); } @@ -281,11 +281,11 @@ Ox.fallback.reduce = function(iterator, ret) { }; /*@ -Ox.fallback.reduceRight see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduceRight - > Ox.fallback.reduceRight.call([1, 2, 3], function(p, c, i) { return p + c + i; }, 1) +Ox.polyfill.reduceRight see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduceRight + > Ox.polyfill.reduceRight.call([1, 2, 3], function(p, c, i) { return p + c + i; }, 1) 10 @*/ -Ox.fallback.reduceRight = function(iterator, ret) { +Ox.polyfill.reduceRight = function(iterator, ret) { if (this === void 0 || this === null || typeof iterator !== 'function') { throw new TypeError(); } @@ -306,13 +306,13 @@ Ox.fallback.reduceRight = function(iterator, ret) { }; /*@ -Ox.fallback.some see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some - > Ox.fallback.some.call([2, 1, 0], function(v, i) { return v == i; }) +Ox.polyfill.some see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some + > Ox.polyfill.some.call([2, 1, 0], function(v, i) { return v == i; }) true - > Ox.fallback.some.call([false, false, false], Ox.identity) + > Ox.polyfill.some.call([false, false, false], Ox.identity) false @*/ -Ox.fallback.some = function(iterator, that) { +Ox.polyfill.some = function(iterator, that) { if (this === void 0 || this === null || typeof iterator !== 'function') { throw new TypeError(); } @@ -327,17 +327,17 @@ Ox.fallback.some = function(iterator, that) { }; /*@ -Ox.fallback.trim see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/Trim - > Ox.fallback.trim.call(' foo ') +Ox.polyfill.trim see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/Trim + > Ox.polyfill.trim.call(' foo ') 'foo' @*/ -Ox.fallback.trim = function() { +Ox.polyfill.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }; (function(global) { var key, log, object; - for (key in Ox.fallback) { + for (key in Ox.polyfill) { object = key == 'bind' ? Function.prototype : key == 'isArray' ? Array : key == 'JSON' ? global @@ -345,7 +345,7 @@ Ox.fallback.trim = function() { : key == 'trim' ? String.prototype : Array.prototype; if (!object[key]) { - object[key] = Ox.fallback[key]; + object[key] = Ox.polyfill[key]; } } // In IE8, window.console.log is an object,