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

Function trustAs

lib/test/angular/1.6.7/angular.js:19359–19377  ·  view source on GitHub ↗

* @ngdoc method * @name $sceDelegate#trustAs * * @description * Returns a trusted representation of the parameter for the specified context. This trusted * object will later on be used as-is, without any security check, by bindings or directives * that require this secu

(type, trustedValue)

Source from the content-addressed store, hash-verified

19357 * @return {*} A trusted representation of value, that can be used in the given context.
19358 */
19359 function trustAs(type, trustedValue) {
19360 var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null);
19361 if (!Constructor) {
19362 throw $sceMinErr('icontext',
19363 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}',
19364 type, trustedValue);
19365 }
19366 if (trustedValue === null || isUndefined(trustedValue) || trustedValue === '') {
19367 return trustedValue;
19368 }
19369 // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting
19370 // mutable objects, we ensure here that the value passed in is actually a string.
19371 if (typeof trustedValue !== 'string') {
19372 throw $sceMinErr('itype',
19373 'Attempted to trust a non-string value in a content requiring a string: Context: {0}',
19374 type);
19375 }
19376 return new Constructor(trustedValue);
19377 }
19378
19379 /**
19380 * @ngdoc method

Callers 1

$SceProviderFunction · 0.70

Calls 1

isUndefinedFunction · 0.70

Tested by

no test coverage detected