diff options
| author | Karl Seamon | 2013-12-09 15:36:15 -0500 | 
|---|---|---|
| committer | Igor Minar | 2013-12-13 00:31:25 -0800 | 
| commit | f3de5b6eac90baf649506072162f36dbc6d2f028 (patch) | |
| tree | e96b658664e7786658e537abc40dc580c22e557e /src/ng/directive/a.js | |
| parent | fcd2a8131a3cb3e59a616bf31e61510b5c3a97d3 (diff) | |
| download | angular.js-f3de5b6eac90baf649506072162f36dbc6d2f028.tar.bz2 | |
perf(a): do not link when href or name exists in template
Change the a directive to link and hookup a click event only when
there is no href or name in the template element.
In a large Google app, this results in about 800 fewer registrations,
saving a small but measurable amount of time and memory.
Closes #5362
Diffstat (limited to 'src/ng/directive/a.js')
| -rw-r--r-- | src/ng/directive/a.js | 18 | 
1 files changed, 10 insertions, 8 deletions
diff --git a/src/ng/directive/a.js b/src/ng/directive/a.js index b3e9ad6d..fe50a79b 100644 --- a/src/ng/directive/a.js +++ b/src/ng/directive/a.js @@ -32,13 +32,15 @@ var htmlAnchorDirective = valueFn({        element.append(document.createComment('IE fix'));      } -    return function(scope, element) { -      element.on('click', function(event){ -        // if we have no href url, then don't navigate anywhere. -        if (!element.attr('href')) { -          event.preventDefault(); -        } -      }); -    }; +    if (!attr.href && !attr.name) { +      return function(scope, element) { +        element.on('click', function(event){ +          // if we have no href url, then don't navigate anywhere. +          if (!element.attr('href')) { +            event.preventDefault(); +          } +        }); +      }; +    }    }  });  | 
