($provide, $$sanitizeUriProvider)
| 6480 | */ |
| 6481 | $CompileProvider.$inject = ['$provide', '$$sanitizeUriProvider']; |
| 6482 | function $CompileProvider($provide, $$sanitizeUriProvider) { |
| 6483 | var hasDirectives = {}, |
| 6484 | Suffix = 'Directive', |
| 6485 | COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\w\-]+)\s+(.*)$/, |
| 6486 | CLASS_DIRECTIVE_REGEXP = /(([\w\-]+)(?:\:([^;]+))?;?)/, |
| 6487 | ALL_OR_NOTHING_ATTRS = makeMap('ngSrc,ngSrcset,src,srcset'), |
| 6488 | REQUIRE_PREFIX_REGEXP = /^(?:(\^\^?)?(\?)?(\^\^?)?)?/; |
| 6489 | |
| 6490 | // Ref: http://developers.whatwg.org/webappapis.html#event-handler-idl-attributes |
| 6491 | // The assumption is that future DOM event attribute names will begin with |
| 6492 | // 'on' and be composed of only English letters. |
| 6493 | var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/; |
| 6494 | |
| 6495 | function parseIsolateBindings(scope, directiveName) { |
| 6496 | var LOCAL_REGEXP = /^\s*([@&]|=(\*?))(\??)\s*(\w*)\s*$/; |
| 6497 | |
| 6498 | var bindings = {}; |
| 6499 | |
| 6500 | forEach(scope, function(definition, scopeName) { |
| 6501 | var match = definition.match(LOCAL_REGEXP); |
| 6502 | |
| 6503 | if (!match) { |
| 6504 | throw $compileMinErr('iscp', |
| 6505 | "Invalid isolate scope definition for directive '{0}'." + |
| 6506 | " Definition: {... {1}: '{2}' ...}", |
| 6507 | directiveName, scopeName, definition); |
| 6508 | } |
| 6509 | |
| 6510 | bindings[scopeName] = { |
| 6511 | mode: match[1][0], |
| 6512 | collection: match[2] === '*', |
| 6513 | optional: match[3] === '?', |
| 6514 | attrName: match[4] || scopeName |
| 6515 | }; |
| 6516 | }); |
| 6517 | |
| 6518 | return bindings; |
| 6519 | } |
| 6520 | |
| 6521 | /** |
| 6522 | * @ngdoc method |
| 6523 | * @name $compileProvider#directive |
| 6524 | * @kind function |
| 6525 | * |
| 6526 | * @description |
| 6527 | * Register a new directive with the compiler. |
| 6528 | * |
| 6529 | * @param {string|Object} name Name of the directive in camel-case (i.e. <code>ngBind</code> which |
| 6530 | * will match as <code>ng-bind</code>), or an object map of directives where the keys are the |
| 6531 | * names and the values are the factories. |
| 6532 | * @param {Function|Array} directiveFactory An injectable directive factory function. See |
| 6533 | * {@link guide/directive} for more info. |
| 6534 | * @returns {ng.$compileProvider} Self for chaining. |
| 6535 | */ |
| 6536 | this.directive = function registerDirective(name, directiveFactory) { |
| 6537 | assertNotHasOwnProperty(name, 'directive'); |
| 6538 | if (isString(name)) { |
| 6539 | assertArg(directiveFactory, 'directiveFactory'); |
nothing calls this directly
no test coverage detected