* @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)
| 17603 | * where Angular expects a $sce.trustAs() return value. |
| 17604 | */ |
| 17605 | function trustAs(type, trustedValue) { |
| 17606 | var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null); |
| 17607 | if (!Constructor) { |
| 17608 | throw $sceMinErr('icontext', |
| 17609 | 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}', |
| 17610 | type, trustedValue); |
| 17611 | } |
| 17612 | if (trustedValue === null || isUndefined(trustedValue) || trustedValue === '') { |
| 17613 | return trustedValue; |
| 17614 | } |
| 17615 | // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting |
| 17616 | // mutable objects, we ensure here that the value passed in is actually a string. |
| 17617 | if (typeof trustedValue !== 'string') { |
| 17618 | throw $sceMinErr('itype', |
| 17619 | 'Attempted to trust a non-string value in a content requiring a string: Context: {0}', |
| 17620 | type); |
| 17621 | } |
| 17622 | return new Constructor(trustedValue); |
| 17623 | } |
| 17624 | |
| 17625 | /** |
| 17626 | * @ngdoc method |
no test coverage detected