MCPcopy Index your code
hub / github.com/angular-ui/ui-router / trustAs

Function trustAs

test/angular/1.6/angular.js:19635–19653  ·  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

19633 * @return {*} A trusted representation of value, that can be used in the given context.
19634 */
19635 function trustAs(type, trustedValue) {
19636 var Constructor = (byType.hasOwnProperty(type) ? byType[type] : null);
19637 if (!Constructor) {
19638 throw $sceMinErr('icontext',
19639 'Attempted to trust a value in invalid context. Context: {0}; Value: {1}',
19640 type, trustedValue);
19641 }
19642 if (trustedValue === null || isUndefined(trustedValue) || trustedValue === '') {
19643 return trustedValue;
19644 }
19645 // All the current contexts in SCE_CONTEXTS happen to be strings. In order to avoid trusting
19646 // mutable objects, we ensure here that the value passed in is actually a string.
19647 if (typeof trustedValue !== 'string') {
19648 throw $sceMinErr('itype',
19649 'Attempted to trust a non-string value in a content requiring a string: Context: {0}',
19650 type);
19651 }
19652 return new Constructor(trustedValue);
19653 }
19654
19655 /**
19656 * @ngdoc method

Callers 1

$SceProviderFunction · 0.70

Calls 1

isUndefinedFunction · 0.70

Tested by

no test coverage detected