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

Function $CompileProvider

test/angular/1.4/angular.js:7244–9206  ·  view source on GitHub ↗
($provide, $$sanitizeUriProvider)

Source from the content-addressed store, hash-verified

7242 */
7243$CompileProvider.$inject = ['$provide', '$$sanitizeUriProvider'];
7244function $CompileProvider($provide, $$sanitizeUriProvider) {
7245 var hasDirectives = {},
7246 Suffix = 'Directive',
7247 COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\w\-]+)\s+(.*)$/,
7248 CLASS_DIRECTIVE_REGEXP = /(([\w\-]+)(?:\:([^;]+))?;?)/,
7249 ALL_OR_NOTHING_ATTRS = makeMap('ngSrc,ngSrcset,src,srcset'),
7250 REQUIRE_PREFIX_REGEXP = /^(?:(\^\^?)?(\?)?(\^\^?)?)?/;
7251
7252 // Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes
7253 // The assumption is that future DOM event attribute names will begin with
7254 // 'on' and be composed of only English letters.
7255 var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/;
7256 var bindingCache = createMap();
7257
7258 function parseIsolateBindings(scope, directiveName, isController) {
7259 var LOCAL_REGEXP = /^\s*([@&]|=(\*?))(\??)\s*(\w*)\s*$/;
7260
7261 var bindings = createMap();
7262
7263 forEach(scope, function(definition, scopeName) {
7264 if (definition in bindingCache) {
7265 bindings[scopeName] = bindingCache[definition];
7266 return;
7267 }
7268 var match = definition.match(LOCAL_REGEXP);
7269
7270 if (!match) {
7271 throw $compileMinErr('iscp',
7272 "Invalid {3} for directive '{0}'." +
7273 " Definition: {... {1}: '{2}' ...}",
7274 directiveName, scopeName, definition,
7275 (isController ? "controller bindings definition" :
7276 "isolate scope definition"));
7277 }
7278
7279 bindings[scopeName] = {
7280 mode: match[1][0],
7281 collection: match[2] === '*',
7282 optional: match[3] === '?',
7283 attrName: match[4] || scopeName
7284 };
7285 if (match[4]) {
7286 bindingCache[definition] = bindings[scopeName];
7287 }
7288 });
7289
7290 return bindings;
7291 }
7292
7293 function parseDirectiveBindings(directive, directiveName) {
7294 var bindings = {
7295 isolateScope: null,
7296 bindToController: null
7297 };
7298 if (isObject(directive.scope)) {
7299 if (directive.bindToController === true) {
7300 bindings.bindToController = parseIsolateBindings(directive.scope,
7301 directiveName, true);

Callers

nothing calls this directly

Calls 15

fnFunction · 0.85
isArrayFunction · 0.85
makeMapFunction · 0.70
createMapFunction · 0.70
assertNotHasOwnPropertyFunction · 0.70
isStringFunction · 0.70
assertValidDirectiveNameFunction · 0.70
assertArgFunction · 0.70
forEachFunction · 0.70
isFunctionFunction · 0.70
valueFnFunction · 0.70
reverseParamsFunction · 0.70

Tested by

no test coverage detected