MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / $SceProvider

Function $SceProvider

lib/test/angular/1.6.7/angular.js:19762–20169  ·  view source on GitHub ↗

* @ngdoc service * @name $sce * @kind function * * @description * * `$sce` is a service that provides Strict Contextual Escaping services to AngularJS. * * ## Strict Contextual Escaping * * Strict Contextual Escaping (SCE) is a mode in which AngularJS constrains bindings to only render *

()

Source from the content-addressed store, hash-verified

19760 */
19761
19762function $SceProvider() {
19763 var enabled = true;
19764
19765 /**
19766 * @ngdoc method
19767 * @name $sceProvider#enabled
19768 * @kind function
19769 *
19770 * @param {boolean=} value If provided, then enables/disables SCE application-wide.
19771 * @return {boolean} True if SCE is enabled, false otherwise.
19772 *
19773 * @description
19774 * Enables/disables SCE and returns the current value.
19775 */
19776 this.enabled = function(value) {
19777 if (arguments.length) {
19778 enabled = !!value;
19779 }
19780 return enabled;
19781 };
19782
19783
19784 /* Design notes on the default implementation for SCE.
19785 *
19786 * The API contract for the SCE delegate
19787 * -------------------------------------
19788 * The SCE delegate object must provide the following 3 methods:
19789 *
19790 * - trustAs(contextEnum, value)
19791 * This method is used to tell the SCE service that the provided value is OK to use in the
19792 * contexts specified by contextEnum. It must return an object that will be accepted by
19793 * getTrusted() for a compatible contextEnum and return this value.
19794 *
19795 * - valueOf(value)
19796 * For values that were not produced by trustAs(), return them as is. For values that were
19797 * produced by trustAs(), return the corresponding input value to trustAs. Basically, if
19798 * trustAs is wrapping the given values into some type, this operation unwraps it when given
19799 * such a value.
19800 *
19801 * - getTrusted(contextEnum, value)
19802 * This function should return the a value that is safe to use in the context specified by
19803 * contextEnum or throw and exception otherwise.
19804 *
19805 * NOTE: This contract deliberately does NOT state that values returned by trustAs() must be
19806 * opaque or wrapped in some holder object. That happens to be an implementation detail. For
19807 * instance, an implementation could maintain a registry of all trusted objects by context. In
19808 * such a case, trustAs() would return the same object that was passed in. getTrusted() would
19809 * return the same object passed in if it was found in the registry under a compatible context or
19810 * throw an exception otherwise. An implementation might only wrap values some of the time based
19811 * on some criteria. getTrusted() might return a value and not throw an exception for special
19812 * constants or objects even if not wrapped. All such implementations fulfill this contract.
19813 *
19814 *
19815 * A note on the inheritance model for SCE contexts
19816 * ------------------------------------------------
19817 * I've used inheritance and made RESOURCE_URL wrapped types a subtype of URL wrapped types. This
19818 * is purely an implementation details.
19819 *

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected