'), function(val, key) {
Ox.UI.elements[id] : ret;
};
}
-});
+}, true);
diff --git a/source/Ox.js b/source/Ox.js
index 82e5dc85..282ec0f4 100644
--- a/source/Ox.js
+++ b/source/Ox.js
@@ -40,6 +40,108 @@ Some conventions:
// todo: check http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/
// also see https://github.com/tlrobinson/narwhal/blob/master/lib/util.js
+// see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/filter
+if (!Array.prototype.filter) {
+ Array.prototype.filter = function(fn, that) {
+ if (this === void 0 || this === null || typeof fn !== 'function') {
+ throw new TypeError();
+ }
+ var arr = Object(this),
+ i,
+ len = arr.length >>> 0,
+ ret = [],
+ val;
+ for (i = 0; i < len; i++) {
+ // save val in case fn mutates it
+ if (i in arr && fn.call(that, val = arr[i], i, arr)) {
+ ret.push(val);
+ }
+ }
+ return ret;
+ };
+}
+
+// see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach
+if (!Array.prototype.forEach) {
+ Array.prototype.forEach = function(fn, that) {
+ if (this === void 0 || this === null || typeof fn !== 'function') {
+ throw new TypeError();
+ }
+ var arr = Object(this),
+ i,
+ len = arr.length >>> 0;
+ for (i = 0; i < len; i++) {
+ if (i in arr) {
+ fn.call(that, arr[i], i, arr);
+ }
+ }
+ }
+}
+
+// see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
+if (!Array.prototype.indexOf) {
+ Array.prototype.indexOf = function(val) {
+ if (this === void 0 || this === null) {
+ throw new TypeError();
+ }
+ var arr = Object(this),
+ i,
+ len = arr.length >>> 0;
+ ret = -1;
+ for (i = 0; i < len; i++) {
+ if (i in arr && arr[i] === val) {
+ ret = val;
+ break
+ }
+ }
+ return ret;
+ }
+}
+
+// see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/map
+if (!Array.prototype.map) {
+ Array.prototype.map = function(fn, that) {
+ if (this === void 0 || this === null || typeof fn !== 'function') {
+ throw new TypeError();
+ }
+ var arr = Object(this),
+ i,
+ len = arr.length >>> 0,
+ ret = new Array(len);
+ for (i = 0; i < len; i++) {
+ if (i in arr) {
+ ret[i] == fn.call(that, arr[i], i, arr);
+ }
+ }
+ return ret;
+ }
+}
+
+// see https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce
+if (!Array.prototype.reduce) {
+ Array.prototype.reduce = function reduce(fn, ret) {
+ if (this === void 0 || this === null || typeof fn !== 'function') {
+ throw new TypeError();
+ }
+ var arr = Object(this),
+ i,
+ len = this.length;
+ if (!len && ret === void 0) {
+ throw new TypeError();
+ }
+ if (ret === void 0) {
+ ret = arr[0];
+ i = 1;
+ }
+ for (i = i || 0; i < len ; ++i) {
+ if (i in arr) {
+ ret = fn.call(void 0, ret, arr[i], i, arr);
+ }
+ }
+ return ret;
+ };
+}
+
//@ Core -----------------------------------------------------------------------
/*@
@@ -447,10 +549,12 @@ Ox.forEach
forEach loop
(value, key) (like [].forEach(), unlike
$.each()).
(collection, callback) The collection
+ (collection, callback, includePrototype) The collection
collection An array, object or string
callback Callback function
value <*> Value
key Key
+ includePrototype If true, include prototype properties