From 78c7066422a9c800e7d527a4ed588a138a326551 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 7 Nov 2011 21:54:01 -0800 Subject: refactor(angular): isDate / isArray test iframe independent fix --- src/Angular.js | 14 +++++--- src/Injector.js | 6 ++-- src/angular-mocks.js | 83 +++++++++++++++++++++++------------------------ test/angular-mocksSpec.js | 5 +++ 4 files changed, 58 insertions(+), 50 deletions(-) diff --git a/src/Angular.js b/src/Angular.js index 0dfea2f4..72a892e5 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -80,7 +80,6 @@ var _undefined = undefined, $name = 'name', $noop = 'noop', $null = 'null', - $number = 'number', $object = 'object', $string = 'string', $value = 'value', @@ -94,6 +93,7 @@ var _undefined = undefined, jQuery, // delay binding slice = [].slice, push = [].push, + toString = Object.prototype.toString, error = window[$console] ? bind(window[$console], window[$console]['error'] || noop) : noop, @@ -363,7 +363,7 @@ function isString(value){return typeof value == $string;} * @param {*} value Reference to check. * @returns {boolean} True if `value` is a `Number`. */ -function isNumber(value){return typeof value == $number;} +function isNumber(value){return typeof value == 'number';} /** @@ -377,7 +377,9 @@ function isNumber(value){return typeof value == $number;} * @param {*} value Reference to check. * @returns {boolean} True if `value` is a `Date`. */ -function isDate(value){return value instanceof Date;} +function isDate(value){ + return toString.apply(value) == '[object Date]'; +} /** @@ -391,7 +393,9 @@ function isDate(value){return value instanceof Date;} * @param {*} value Reference to check. * @returns {boolean} True if `value` is an `Array`. */ -function isArray(value) {return value instanceof Array;} +function isArray(value) { + return toString.apply(value) == '[object Array]'; +} /** @@ -769,7 +773,7 @@ function equals(o1, o2) { if (o1 === null || o2 === null) return false; var t1 = typeof o1, t2 = typeof o2, length, key, keySet; if (t1 == t2 && t1 == 'object') { - if (o1 instanceof Array) { + if (isArray(o1)) { if ((length = o1.length) == o2.length) { for(key=0; key