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

Function $SceProvider

test/angular/1.3/angular.js:15703–16099  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15701/* jshint maxlen: 100 */
15702
15703function $SceProvider() {
15704 var enabled = true;
15705
15706 /**
15707 * @ngdoc method
15708 * @name $sceProvider#enabled
15709 * @kind function
15710 *
15711 * @param {boolean=} value If provided, then enables/disables SCE.
15712 * @return {boolean} true if SCE is enabled, false otherwise.
15713 *
15714 * @description
15715 * Enables/disables SCE and returns the current value.
15716 */
15717 this.enabled = function(value) {
15718 if (arguments.length) {
15719 enabled = !!value;
15720 }
15721 return enabled;
15722 };
15723
15724
15725 /* Design notes on the default implementation for SCE.
15726 *
15727 * The API contract for the SCE delegate
15728 * -------------------------------------
15729 * The SCE delegate object must provide the following 3 methods:
15730 *
15731 * - trustAs(contextEnum, value)
15732 * This method is used to tell the SCE service that the provided value is OK to use in the
15733 * contexts specified by contextEnum. It must return an object that will be accepted by
15734 * getTrusted() for a compatible contextEnum and return this value.
15735 *
15736 * - valueOf(value)
15737 * For values that were not produced by trustAs(), return them as is. For values that were
15738 * produced by trustAs(), return the corresponding input value to trustAs. Basically, if
15739 * trustAs is wrapping the given values into some type, this operation unwraps it when given
15740 * such a value.
15741 *
15742 * - getTrusted(contextEnum, value)
15743 * This function should return the a value that is safe to use in the context specified by
15744 * contextEnum or throw and exception otherwise.
15745 *
15746 * NOTE: This contract deliberately does NOT state that values returned by trustAs() must be
15747 * opaque or wrapped in some holder object. That happens to be an implementation detail. For
15748 * instance, an implementation could maintain a registry of all trusted objects by context. In
15749 * such a case, trustAs() would return the same object that was passed in. getTrusted() would
15750 * return the same object passed in if it was found in the registry under a compatible context or
15751 * throw an exception otherwise. An implementation might only wrap values some of the time based
15752 * on some criteria. getTrusted() might return a value and not throw an exception for special
15753 * constants or objects even if not wrapped. All such implementations fulfill this contract.
15754 *
15755 *
15756 * A note on the inheritance model for SCE contexts
15757 * ------------------------------------------------
15758 * I've used inheritance and made RESOURCE_URL wrapped types a subtype of URL wrapped types. This
15759 * is purely an implementation details.
15760 *

Callers

nothing calls this directly

Calls 8

shallowCopyFunction · 0.70
forEachFunction · 0.70
lowercaseFunction · 0.70
camelCaseFunction · 0.70
parseFunction · 0.70
getTrustedFunction · 0.70
trustAsFunction · 0.70
$parseFunction · 0.50

Tested by

no test coverage detected