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

Function $SceProvider

lib/test/angular/1.4.3/angular.js:16984–17380  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16982/* jshint maxlen: 100 */
16983
16984function $SceProvider() {
16985 var enabled = true;
16986
16987 /**
16988 * @ngdoc method
16989 * @name $sceProvider#enabled
16990 * @kind function
16991 *
16992 * @param {boolean=} value If provided, then enables/disables SCE.
16993 * @return {boolean} true if SCE is enabled, false otherwise.
16994 *
16995 * @description
16996 * Enables/disables SCE and returns the current value.
16997 */
16998 this.enabled = function(value) {
16999 if (arguments.length) {
17000 enabled = !!value;
17001 }
17002 return enabled;
17003 };
17004
17005
17006 /* Design notes on the default implementation for SCE.
17007 *
17008 * The API contract for the SCE delegate
17009 * -------------------------------------
17010 * The SCE delegate object must provide the following 3 methods:
17011 *
17012 * - trustAs(contextEnum, value)
17013 * This method is used to tell the SCE service that the provided value is OK to use in the
17014 * contexts specified by contextEnum. It must return an object that will be accepted by
17015 * getTrusted() for a compatible contextEnum and return this value.
17016 *
17017 * - valueOf(value)
17018 * For values that were not produced by trustAs(), return them as is. For values that were
17019 * produced by trustAs(), return the corresponding input value to trustAs. Basically, if
17020 * trustAs is wrapping the given values into some type, this operation unwraps it when given
17021 * such a value.
17022 *
17023 * - getTrusted(contextEnum, value)
17024 * This function should return the a value that is safe to use in the context specified by
17025 * contextEnum or throw and exception otherwise.
17026 *
17027 * NOTE: This contract deliberately does NOT state that values returned by trustAs() must be
17028 * opaque or wrapped in some holder object. That happens to be an implementation detail. For
17029 * instance, an implementation could maintain a registry of all trusted objects by context. In
17030 * such a case, trustAs() would return the same object that was passed in. getTrusted() would
17031 * return the same object passed in if it was found in the registry under a compatible context or
17032 * throw an exception otherwise. An implementation might only wrap values some of the time based
17033 * on some criteria. getTrusted() might return a value and not throw an exception for special
17034 * constants or objects even if not wrapped. All such implementations fulfill this contract.
17035 *
17036 *
17037 * A note on the inheritance model for SCE contexts
17038 * ------------------------------------------------
17039 * I've used inheritance and made RESOURCE_URL wrapped types a subtype of URL wrapped types. This
17040 * is purely an implementation details.
17041 *

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