* @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
(type, trustedValue)
| 18075 | * where Angular expects a $sce.trustAs() return value. |
| 18076 | */ |
| 18077 | function trustAs(type, trustedValue) { |
| 18078 | var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null); |
| 18079 | if (!Constructor) { |
| 18080 | throw $sceMinErr('icontext', |
| 18081 | 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}', |
| 18082 | type, |
| 18083 | trustedValue); |
| 18084 | } |
| 18085 | if (trustedValue === null || isUndefined(trustedValue) || trustedValue === '') { |
| 18086 | return trustedValue; |
| 18087 | } |
| 18088 | // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting |
| 18089 | // mutable objects, we ensure here that the value passed in is actually a string. |
| 18090 | if (typeof trustedValue !== 'string') { |
| 18091 | throw $sceMinErr('itype', |
| 18092 | 'Attempted to trust a non-string value in a content requiring a string: Context: {0}', |
| 18093 | type); |
| 18094 | } |
| 18095 | return new Constructor(trustedValue); |
| 18096 | } |
| 18097 | |
| 18098 | /** |
| 18099 | * @ngdoc method |
no test coverage detected