From f3de5b6eac90baf649506072162f36dbc6d2f028 Mon Sep 17 00:00:00 2001
From: Karl Seamon
Date: Mon, 9 Dec 2013 15:36:15 -0500
Subject: 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
---
test/ng/directive/aSpec.js | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
(limited to 'test')
diff --git a/test/ng/directive/aSpec.js b/test/ng/directive/aSpec.js
index a284f4bc..dc0de729 100644
--- a/test/ng/directive/aSpec.js
+++ b/test/ng/directive/aSpec.js
@@ -58,4 +58,30 @@ describe('a', function() {
expect(element.text()).toBe('hello@you');
});
+
+
+ it('should not link and hookup an event if href is present at compile', function() {
+ var jq = jQuery || jqLite;
+ element = jq('hello@you');
+ var linker = $compile(element);
+
+ spyOn(jq.prototype, 'on');
+
+ linker($rootScope);
+
+ expect(jq.prototype.on).not.toHaveBeenCalled();
+ });
+
+
+ it('should not link and hookup an event if name is present at compile', function() {
+ var jq = jQuery || jqLite;
+ element = jq('hello@you');
+ var linker = $compile(element);
+
+ spyOn(jq.prototype, 'on');
+
+ linker($rootScope);
+
+ expect(jq.prototype.on).not.toHaveBeenCalled();
+ });
});
--
cgit v1.2.3