(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn)
| 4289 | |
| 4290 | |
| 4291 | function nodeLinkFn(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn) { |
| 4292 | var attrs, $element, i, ii, linkFn, controller; |
| 4293 | |
| 4294 | if (compileNode === linkNode) { |
| 4295 | attrs = templateAttrs; |
| 4296 | } else { |
| 4297 | attrs = shallowCopy(templateAttrs, new Attributes(jqLite(linkNode), templateAttrs.$attr)); |
| 4298 | } |
| 4299 | $element = attrs.$$element; |
| 4300 | |
| 4301 | if (newIsolateScopeDirective) { |
| 4302 | var LOCAL_REGEXP = /^\s*([@=&])\s*(\w*)\s*$/; |
| 4303 | |
| 4304 | var parentScope = scope.$parent || scope; |
| 4305 | |
| 4306 | forEach(newIsolateScopeDirective.scope, function(definiton, scopeName) { |
| 4307 | var match = definiton.match(LOCAL_REGEXP) || [], |
| 4308 | attrName = match[2]|| scopeName, |
| 4309 | mode = match[1], // @, =, or & |
| 4310 | lastValue, |
| 4311 | parentGet, parentSet; |
| 4312 | |
| 4313 | scope.$$isolateBindings[scopeName] = mode + attrName; |
| 4314 | |
| 4315 | switch (mode) { |
| 4316 | |
| 4317 | case '@': { |
| 4318 | attrs.$observe(attrName, function(value) { |
| 4319 | scope[scopeName] = value; |
| 4320 | }); |
| 4321 | attrs.$$observers[attrName].$$scope = parentScope; |
| 4322 | break; |
| 4323 | } |
| 4324 | |
| 4325 | case '=': { |
| 4326 | parentGet = $parse(attrs[attrName]); |
| 4327 | parentSet = parentGet.assign || function() { |
| 4328 | // reset the change, or we will throw this exception on every $digest |
| 4329 | lastValue = scope[scopeName] = parentGet(parentScope); |
| 4330 | throw Error(NON_ASSIGNABLE_MODEL_EXPRESSION + attrs[attrName] + |
| 4331 | ' (directive: ' + newIsolateScopeDirective.name + ')'); |
| 4332 | }; |
| 4333 | lastValue = scope[scopeName] = parentGet(parentScope); |
| 4334 | scope.$watch(function parentValueWatch() { |
| 4335 | var parentValue = parentGet(parentScope); |
| 4336 | |
| 4337 | if (parentValue !== scope[scopeName]) { |
| 4338 | // we are out of sync and need to copy |
| 4339 | if (parentValue !== lastValue) { |
| 4340 | // parent changed and it has precedence |
| 4341 | lastValue = scope[scopeName] = parentValue; |
| 4342 | } else { |
| 4343 | // if the parent can be assigned then do so |
| 4344 | parentSet(parentScope, parentValue = lastValue = scope[scopeName]); |
| 4345 | } |
| 4346 | } |
| 4347 | return parentValue; |
| 4348 | }); |
no test coverage detected