diff options
Diffstat (limited to 'src/Angular.js')
| -rw-r--r-- | src/Angular.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/Angular.js b/src/Angular.js index 746f1134..02dadf8d 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -414,6 +414,18 @@ function isFunction(value){return typeof value == 'function';} /** + * Determines if a value is a regular expression object. + * + * @private + * @param {*} value Reference to check. + * @returns {boolean} True if `value` is a `RegExp`. + */ +function isRegExp(value) { + return toString.apply(value) == '[object RegExp]'; +} + + +/** * Checks if `obj` is a window object. * * @private @@ -646,7 +658,7 @@ function shallowCopy(src, dst) { * @function * * @description - * Determines if two objects or two values are equivalent. Supports value types, arrays and + * Determines if two objects or two values are equivalent. Supports value types, regular expressions, arrays and * objects. * * Two objects or values are considered equivalent if at least one of the following is true: @@ -654,6 +666,9 @@ function shallowCopy(src, dst) { * * Both objects or values pass `===` comparison. * * Both objects or values are of the same type and all of their properties pass `===` comparison. * * Both values are NaN. (In JavasScript, NaN == NaN => false. But we consider two NaN as equal) + * * Both values represent the same regular expression (In JavasScript, + * /abc/ == /abc/ => false. But we consider two regular expressions as equal when their textual + * representation matches). * * During a property comparison, properties of `function` type and properties with names * that begin with `$` are ignored. @@ -680,6 +695,8 @@ function equals(o1, o2) { } } else if (isDate(o1)) { return isDate(o2) && o1.getTime() == o2.getTime(); + } else if (isRegExp(o1) && isRegExp(o2)) { + return o1.toString() == o2.toString(); } else { if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2)) return false; keySet = {}; @@ -949,9 +966,9 @@ function encodeUriQuery(val, pctEncodeSpaces) { * one ngApp directive can be used per HTML document. The directive * designates the root of the application and is typically placed * at the root of the page. - * - * The first ngApp found in the document will be auto-bootstrapped. To use multiple applications in an - * HTML document you must manually bootstrap them using {@link angular.bootstrap}. + * + * The first ngApp found in the document will be auto-bootstrapped. To use multiple applications in an + * HTML document you must manually bootstrap them using {@link angular.bootstrap}. * Applications cannot be nested. * * In the example below if the `ngApp` directive would not be placed |
