MCPcopy Create free account
hub / github.com/angular-ui/ui-router / trustAs

Function trustAs

test/angular/1.3/angular.js:15329–15347  ·  view source on GitHub ↗

* @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)

Source from the content-addressed store, hash-verified

15327 * where Angular expects a $sce.trustAs() return value.
15328 */
15329 function trustAs(type, trustedValue) {
15330 var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null);
15331 if (!Constructor) {
15332 throw $sceMinErr('icontext',
15333 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}',
15334 type, trustedValue);
15335 }
15336 if (trustedValue === null || trustedValue === undefined || trustedValue === '') {
15337 return trustedValue;
15338 }
15339 // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting
15340 // mutable objects, we ensure here that the value passed in is actually a string.
15341 if (typeof trustedValue !== 'string') {
15342 throw $sceMinErr('itype',
15343 'Attempted to trust a non-string value in a content requiring a string: Context: {0}',
15344 type);
15345 }
15346 return new Constructor(trustedValue);
15347 }
15348
15349 /**
15350 * @ngdoc method

Callers 1

$SceProviderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected