(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn)
| 7534 | |
| 7535 | |
| 7536 | function nodeLinkFn(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn) { |
| 7537 | var i, ii, linkFn, controller, isolateScope, elementControllers, transcludeFn, $element, |
| 7538 | attrs; |
| 7539 | |
| 7540 | if (compileNode === linkNode) { |
| 7541 | attrs = templateAttrs; |
| 7542 | $element = templateAttrs.$$element; |
| 7543 | } else { |
| 7544 | $element = jqLite(linkNode); |
| 7545 | attrs = new Attributes($element, templateAttrs); |
| 7546 | } |
| 7547 | |
| 7548 | if (newIsolateScopeDirective) { |
| 7549 | isolateScope = scope.$new(true); |
| 7550 | } |
| 7551 | |
| 7552 | if (boundTranscludeFn) { |
| 7553 | // track `boundTranscludeFn` so it can be unwrapped if `transcludeFn` |
| 7554 | // is later passed as `parentBoundTranscludeFn` to `publicLinkFn` |
| 7555 | transcludeFn = controllersBoundTransclude; |
| 7556 | transcludeFn.$$boundTransclude = boundTranscludeFn; |
| 7557 | } |
| 7558 | |
| 7559 | if (controllerDirectives) { |
| 7560 | // TODO: merge `controllers` and `elementControllers` into single object. |
| 7561 | controllers = {}; |
| 7562 | elementControllers = {}; |
| 7563 | forEach(controllerDirectives, function(directive) { |
| 7564 | var locals = { |
| 7565 | $scope: directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope, |
| 7566 | $element: $element, |
| 7567 | $attrs: attrs, |
| 7568 | $transclude: transcludeFn |
| 7569 | }, controllerInstance; |
| 7570 | |
| 7571 | controller = directive.controller; |
| 7572 | if (controller == '@') { |
| 7573 | controller = attrs[directive.name]; |
| 7574 | } |
| 7575 | |
| 7576 | controllerInstance = $controller(controller, locals, true, directive.controllerAs); |
| 7577 | |
| 7578 | // For directives with element transclusion the element is a comment, |
| 7579 | // but jQuery .data doesn't support attaching data to comment nodes as it's hard to |
| 7580 | // clean up (http://bugs.jquery.com/ticket/8335). |
| 7581 | // Instead, we save the controllers for the element in a local hash and attach to .data |
| 7582 | // later, once we have the actual element. |
| 7583 | elementControllers[directive.name] = controllerInstance; |
| 7584 | if (!hasElementTranscludeDirective) { |
| 7585 | $element.data('$' + directive.name + 'Controller', controllerInstance.instance); |
| 7586 | } |
| 7587 | |
| 7588 | controllers[directive.name] = controllerInstance; |
| 7589 | }); |
| 7590 | } |
| 7591 | |
| 7592 | if (newIsolateScopeDirective) { |
| 7593 | compile.$$addScopeInfo($element, isolateScope, true, !(templateDirective && (templateDirective === newIsolateScopeDirective || |
no test coverage detected