* @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)
| 18787 | * where Angular expects a $sce.trustAs() return value. |
| 18788 | */ |
| 18789 | function trustAs(type, trustedValue) { |
| 18790 | var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null); |
| 18791 | if (!Constructor) { |
| 18792 | throw $sceMinErr('icontext', |
| 18793 | 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}', |
| 18794 | type, trustedValue); |
| 18795 | } |
| 18796 | if (trustedValue === null || isUndefined(trustedValue) || trustedValue === '') { |
| 18797 | return trustedValue; |
| 18798 | } |
| 18799 | // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting |
| 18800 | // mutable objects, we ensure here that the value passed in is actually a string. |
| 18801 | if (typeof trustedValue !== 'string') { |
| 18802 | throw $sceMinErr('itype', |
| 18803 | 'Attempted to trust a non-string value in a content requiring a string: Context: {0}', |
| 18804 | type); |
| 18805 | } |
| 18806 | return new Constructor(trustedValue); |
| 18807 | } |
| 18808 | |
| 18809 | /** |
| 18810 | * @ngdoc method |
no test coverage detected