MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / $CompileProvider

Function $CompileProvider

code/songhop/www/lib/angular/angular.js:6404–8200  ·  view source on GitHub ↗
($provide, $$sanitizeUriProvider)

Source from the content-addressed store, hash-verified

6402 */
6403$CompileProvider.$inject = ['$provide', '$$sanitizeUriProvider'];
6404function $CompileProvider($provide, $$sanitizeUriProvider) {
6405 var hasDirectives = {},
6406 Suffix = 'Directive',
6407 COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\w\-]+)\s+(.*)$/,
6408 CLASS_DIRECTIVE_REGEXP = /(([\w\-]+)(?:\:([^;]+))?;?)/,
6409 ALL_OR_NOTHING_ATTRS = makeMap('ngSrc,ngSrcset,src,srcset'),
6410 REQUIRE_PREFIX_REGEXP = /^(?:(\^\^?)?(\?)?(\^\^?)?)?/;
6411
6412 // Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes
6413 // The assumption is that future DOM event attribute names will begin with
6414 // 'on' and be composed of only English letters.
6415 var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/;
6416
6417 function parseIsolateBindings(scope, directiveName) {
6418 var LOCAL_REGEXP = /^\s*([@&]|=(\*?))(\??)\s*(\w*)\s*$/;
6419
6420 var bindings = {};
6421
6422 forEach(scope, function(definition, scopeName) {
6423 var match = definition.match(LOCAL_REGEXP);
6424
6425 if (!match) {
6426 throw $compileMinErr('iscp',
6427 "Invalid isolate scope definition for directive '{0}'." +
6428 " Definition: {... {1}: '{2}' ...}",
6429 directiveName, scopeName, definition);
6430 }
6431
6432 bindings[scopeName] = {
6433 mode: match[1][0],
6434 collection: match[2] === '*',
6435 optional: match[3] === '?',
6436 attrName: match[4] || scopeName
6437 };
6438 });
6439
6440 return bindings;
6441 }
6442
6443 /**
6444 * @ngdoc method
6445 * @name $compileProvider#directive
6446 * @kind function
6447 *
6448 * @description
6449 * Register a new directive with the compiler.
6450 *
6451 * @param {string|Object} name Name of the directive in camel-case (i.e. <code>ngBind</code> which
6452 * will match as <code>ng-bind</code>), or an object map of directives where the keys are the
6453 * names and the values are the factories.
6454 * @param {Function|Array} directiveFactory An injectable directive factory function. See
6455 * {@link guide/directive} for more info.
6456 * @returns {ng.$compileProvider} Self for chaining.
6457 */
6458 this.directive = function registerDirective(name, directiveFactory) {
6459 assertNotHasOwnProperty(name, 'directive');
6460 if (isString(name)) {
6461 assertArg(directiveFactory, 'directiveFactory');

Callers

nothing calls this directly

Calls 15

concatMethod · 0.80
makeMapFunction · 0.70
assertNotHasOwnPropertyFunction · 0.70
isStringFunction · 0.70
assertArgFunction · 0.70
forEachFunction · 0.70
isFunctionFunction · 0.70
valueFnFunction · 0.70
isObjectFunction · 0.70
parseIsolateBindingsFunction · 0.70
reverseParamsFunction · 0.70
isDefinedFunction · 0.70

Tested by

no test coverage detected