* @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)
| 15098 | * where Angular expects a $sce.trustAs() return value. |
| 15099 | */ |
| 15100 | function trustAs(type, trustedValue) { |
| 15101 | var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null); |
| 15102 | if (!Constructor) { |
| 15103 | throw $sceMinErr('icontext', |
| 15104 | 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}', |
| 15105 | type, trustedValue); |
| 15106 | } |
| 15107 | if (trustedValue === null || trustedValue === undefined || trustedValue === '') { |
| 15108 | return trustedValue; |
| 15109 | } |
| 15110 | // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting |
| 15111 | // mutable objects, we ensure here that the value passed in is actually a string. |
| 15112 | if (typeof trustedValue !== 'string') { |
| 15113 | throw $sceMinErr('itype', |
| 15114 | 'Attempted to trust a non-string value in a content requiring a string: Context: {0}', |
| 15115 | type); |
| 15116 | } |
| 15117 | return new Constructor(trustedValue); |
| 15118 | } |
| 15119 | |
| 15120 | /** |
| 15121 | * @ngdoc method |