* @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)
| 13580 | * where Angular expects a $sce.trustAs() return value. |
| 13581 | */ |
| 13582 | function trustAs(type, trustedValue) { |
| 13583 | var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null); |
| 13584 | if (!Constructor) { |
| 13585 | throw $sceMinErr('icontext', |
| 13586 | 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}', |
| 13587 | type, trustedValue); |
| 13588 | } |
| 13589 | if (trustedValue === null || trustedValue === undefined || trustedValue === '') { |
| 13590 | return trustedValue; |
| 13591 | } |
| 13592 | // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting |
| 13593 | // mutable objects, we ensure here that the value passed in is actually a string. |
| 13594 | if (typeof trustedValue !== 'string') { |
| 13595 | throw $sceMinErr('itype', |
| 13596 | 'Attempted to trust a non-string value in a content requiring a string: Context: {0}', |
| 13597 | type); |
| 13598 | } |
| 13599 | return new Constructor(trustedValue); |
| 13600 | } |
| 13601 | |
| 13602 | /** |
| 13603 | * @ngdoc method |