($provide, $$sanitizeUriProvider)
| 5686 | */ |
| 5687 | $CompileProvider.$inject = ['$provide', '$$sanitizeUriProvider']; |
| 5688 | function $CompileProvider($provide, $$sanitizeUriProvider) { |
| 5689 | var hasDirectives = {}, |
| 5690 | Suffix = 'Directive', |
| 5691 | COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\d\w_\-]+)\s+(.*)$/, |
| 5692 | CLASS_DIRECTIVE_REGEXP = /(([\d\w_\-]+)(?:\:([^;]+))?;?)/; |
| 5693 | |
| 5694 | // Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes |
| 5695 | // The assumption is that future DOM event attribute names will begin with |
| 5696 | // 'on' and be composed of only English letters. |
| 5697 | var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/; |
| 5698 | |
| 5699 | /** |
| 5700 | * @ngdoc method |
| 5701 | * @name $compileProvider#directive |
| 5702 | * @kind function |
| 5703 | * |
| 5704 | * @description |
| 5705 | * Register a new directive with the compiler. |
| 5706 | * |
| 5707 | * @param {string|Object} name Name of the directive in camel-case (i.e. <code>ngBind</code> which |
| 5708 | * will match as <code>ng-bind</code>), or an object map of directives where the keys are the |
| 5709 | * names and the values are the factories. |
| 5710 | * @param {Function|Array} directiveFactory An injectable directive factory function. See |
| 5711 | * {@link guide/directive} for more info. |
| 5712 | * @returns {ng.$compileProvider} Self for chaining. |
| 5713 | */ |
| 5714 | this.directive = function registerDirective(name, directiveFactory) { |
| 5715 | assertNotHasOwnProperty(name, 'directive'); |
| 5716 | if (isString(name)) { |
| 5717 | assertArg(directiveFactory, 'directiveFactory'); |
| 5718 | if (!hasDirectives.hasOwnProperty(name)) { |
| 5719 | hasDirectives[name] = []; |
| 5720 | $provide.factory(name + Suffix, ['$injector', '$exceptionHandler', |
| 5721 | function($injector, $exceptionHandler) { |
| 5722 | var directives = []; |
| 5723 | forEach(hasDirectives[name], function(directiveFactory, index) { |
| 5724 | try { |
| 5725 | var directive = $injector.invoke(directiveFactory); |
| 5726 | if (isFunction(directive)) { |
| 5727 | directive = { compile: valueFn(directive) }; |
| 5728 | } else if (!directive.compile && directive.link) { |
| 5729 | directive.compile = valueFn(directive.link); |
| 5730 | } |
| 5731 | directive.priority = directive.priority || 0; |
| 5732 | directive.index = index; |
| 5733 | directive.name = directive.name || name; |
| 5734 | directive.require = directive.require || (directive.controller && directive.name); |
| 5735 | directive.restrict = directive.restrict || 'A'; |
| 5736 | directives.push(directive); |
| 5737 | } catch (e) { |
| 5738 | $exceptionHandler(e); |
| 5739 | } |
| 5740 | }); |
| 5741 | return directives; |
| 5742 | }]); |
| 5743 | } |
| 5744 | hasDirectives[name].push(directiveFactory); |
| 5745 | } else { |
nothing calls this directly
no test coverage detected