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
		
			
				
	
	
		
			17 lines
		
	
	
		
			383 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			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;
 | |
| }
 |