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

Function $SceProvider

test/angular/1.4/angular.js:17543–17939  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17541/* jshint maxlen: 100 */
17542
17543function $SceProvider() {
17544 var enabled = true;
17545
17546 /**
17547 * @ngdoc method
17548 * @name $sceProvider#enabled
17549 * @kind function
17550 *
17551 * @param {boolean=} value If provided, then enables/disables SCE.
17552 * @return {boolean} true if SCE is enabled, false otherwise.
17553 *
17554 * @description
17555 * Enables/disables SCE and returns the current value.
17556 */
17557 this.enabled = function(value) {
17558 if (arguments.length) {
17559 enabled = !!value;
17560 }
17561 return enabled;
17562 };
17563
17564
17565 /* Design notes on the default implementation for SCE.
17566 *
17567 * The API contract for the SCE delegate
17568 * -------------------------------------
17569 * The SCE delegate object must provide the following 3 methods:
17570 *
17571 * - trustAs(contextEnum, value)
17572 * This method is used to tell the SCE service that the provided value is OK to use in the
17573 * contexts specified by contextEnum. It must return an object that will be accepted by
17574 * getTrusted() for a compatible contextEnum and return this value.
17575 *
17576 * - valueOf(value)
17577 * For values that were not produced by trustAs(), return them as is. For values that were
17578 * produced by trustAs(), return the corresponding input value to trustAs. Basically, if
17579 * trustAs is wrapping the given values into some type, this operation unwraps it when given
17580 * such a value.
17581 *
17582 * - getTrusted(contextEnum, value)
17583 * This function should return the a value that is safe to use in the context specified by
17584 * contextEnum or throw and exception otherwise.
17585 *
17586 * NOTE: This contract deliberately does NOT state that values returned by trustAs() must be
17587 * opaque or wrapped in some holder object. That happens to be an implementation detail. For
17588 * instance, an implementation could maintain a registry of all trusted objects by context. In
17589 * such a case, trustAs() would return the same object that was passed in. getTrusted() would
17590 * return the same object passed in if it was found in the registry under a compatible context or
17591 * throw an exception otherwise. An implementation might only wrap values some of the time based
17592 * on some criteria. getTrusted() might return a value and not throw an exception for special
17593 * constants or objects even if not wrapped. All such implementations fulfill this contract.
17594 *
17595 *
17596 * A note on the inheritance model for SCE contexts
17597 * ------------------------------------------------
17598 * I've used inheritance and made RESOURCE_URL wrapped types a subtype of URL wrapped types. This
17599 * is purely an implementation details.
17600 *

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected