perf(jqLite): expose the low-level jqLite.data/removeData calls

- updated the internal jqLite helpers to use the low-level jqLite.data/removeData to avoid unnecessary jq wrappers and loops
- updated $compile to use the low-level jqLite.data/removeData to avoid unnecessary jq wrappers at link time
This commit is contained in:
Jason Bedard
2014-06-24 00:18:55 -07:00
committed by rodyhaddad
parent a160f76ffa
commit e4ba89436a
3 changed files with 37 additions and 11 deletions

View File

@@ -386,6 +386,7 @@ describe('jqLite', function() {
selected.removeData('prop2');
});
it('should add and remove data on SVGs', function() {
var svg = jqLite('<svg><rect></rect></svg>');
@@ -415,6 +416,27 @@ describe('jqLite', function() {
});
it('should provide the non-wrapped data calls', function() {
var node = document.createElement('div');
expect(jqLite.data(node, "foo")).toBeUndefined();
jqLite.data(node, "foo", "bar");
expect(jqLite.data(node, "foo")).toBe("bar");
expect(jqLite(node).data("foo")).toBe("bar");
expect(jqLite.data(node)).toBe(jqLite(node).data());
jqLite.removeData(node, "foo");
expect(jqLite.data(node, "foo")).toBeUndefined();
jqLite.data(node, "bar", "baz");
jqLite.removeData(node);
jqLite.removeData(node);
expect(jqLite.data(node, "bar")).toBeUndefined();
});
it('should emit $destroy event if element removed via remove()', function() {
var log = '';
var element = jqLite(a);