Skip to content

Commit ce15834

Browse files
committed
fix(watcher): hash-key convertor issue #119
1 parent a2daf58 commit ce15834

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/_provider/watcher.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,20 @@ angular.module('a8m.filter-watcher', [])
4141
* @returns {string}
4242
*/
4343
function getHashKey(fName, args) {
44-
return [fName, angular.toJson(args)]
44+
function replacerFactory() {
45+
var cache = [];
46+
return function(key, val) {
47+
if(isObject(val) && !isNull(val)) {
48+
if (~cache.indexOf(val)) return '[Circular]';
49+
cache.push(val)
50+
}
51+
if($window == val) return '$WINDOW';
52+
if($window.document == val) return '$DOCUMENT';
53+
if(isScope(val)) return '$SCOPE';
54+
return val;
55+
}
56+
}
57+
return [fName, JSON.stringify(args, replacerFactory())]
4558
.join('#')
4659
.replace(/"/g,'');
4760
}
@@ -130,7 +143,6 @@ angular.module('a8m.filter-watcher', [])
130143
isMemoized: $$isMemoized,
131144
memoize: $$memoize
132145
}
133-
134146
}];
135147
});
136148

0 commit comments

Comments
 (0)