Vikram Subramanian a596b887ff feat(compiler): Add an implementation for XHR that uses a template cache to load template files.
Useful for avoiding doing an actual XHR during testing.
Part of the solution for #4051 (Other part is a Karma plugin that will create the template cache).

Closes #7940
2016-04-08 19:05:05 +00:00

17 lines
383 B
Dart

import 'dart:js' as js;
void setTemplateCache(Map cache) {
if (cache == null) {
if (js.context.hasProperty(r'$templateCache')) {
js.context.deleteProperty(r'$templateCache');
}
return;
}
js.JsObject jsMap = new js.JsObject(js.context['Object']);
for (String key in cache.keys) {
jsMap[key] = cache[key];
}
js.context[r'$templateCache'] = jsMap;
}