* @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)
| 16608 | * where Angular expects a $sce.trustAs() return value. |
| 16609 | */ |
| 16610 | function trustAs(type, trustedValue) { |
| 16611 | var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null); |
| 16612 | if (!Constructor) { |
| 16613 | throw $sceMinErr('icontext', |
| 16614 | 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}', |
| 16615 | type, trustedValue); |
| 16616 | } |
| 16617 | if (trustedValue === null || trustedValue === undefined || trustedValue === '') { |
| 16618 | return trustedValue; |
| 16619 | } |
| 16620 | // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting |
| 16621 | // mutable objects, we ensure here that the value passed in is actually a string. |
| 16622 | if (typeof trustedValue !== 'string') { |
| 16623 | throw $sceMinErr('itype', |
| 16624 | 'Attempted to trust a non-string value in a content requiring a string: Context: {0}', |
| 16625 | type); |
| 16626 | } |
| 16627 | return new Constructor(trustedValue); |
| 16628 | } |
| 16629 | |
| 16630 | /** |
| 16631 | * @ngdoc method |