* @ngdoc method * @name $sceDelegate#trustAs * * @description * Returns an object that is trusted by angular for use in specified strict * contextual escaping contexts (such as ng-bind-html, ng-include, any src * attribute interpolation, any dom event binding attribute
(type, trustedValue)
| 15327 | * where Angular expects a $sce.trustAs() return value. |
| 15328 | */ |
| 15329 | function trustAs(type, trustedValue) { |
| 15330 | var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null); |
| 15331 | if (!Constructor) { |
| 15332 | throw $sceMinErr('icontext', |
| 15333 | 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}', |
| 15334 | type, trustedValue); |
| 15335 | } |
| 15336 | if (trustedValue === null || trustedValue === undefined || trustedValue === '') { |
| 15337 | return trustedValue; |
| 15338 | } |
| 15339 | // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting |
| 15340 | // mutable objects, we ensure here that the value passed in is actually a string. |
| 15341 | if (typeof trustedValue !== 'string') { |
| 15342 | throw $sceMinErr('itype', |
| 15343 | 'Attempted to trust a non-string value in a content requiring a string: Context: {0}', |
| 15344 | type); |
| 15345 | } |
| 15346 | return new Constructor(trustedValue); |
| 15347 | } |
| 15348 | |
| 15349 | /** |
| 15350 | * @ngdoc method |