aboutsummaryrefslogtreecommitdiffstats
path: root/test/jqLiteSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2011-07-26 12:06:14 -0700
committerIgor Minar2011-10-11 10:53:05 -0700
commitbda2bba2be7a52bf39fb1b257b6363edc7b71173 (patch)
tree70de396d785f7632377391d3463032826aa2d4c9 /test/jqLiteSpec.js
parentca08c004c893310ed9b3b4a5d2a4d16314eaa677 (diff)
downloadangular.js-bda2bba2be7a52bf39fb1b257b6363edc7b71173.tar.bz2
feat(jqlite): added .inheritedData method and $destroy event.
- refactored .scope() to use .inheritedData() instead. - .bind('$destroy', callback) will call when the DOM element is removed
Diffstat (limited to 'test/jqLiteSpec.js')
-rw-r--r--test/jqLiteSpec.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js
index 24795331..f66b6244 100644
--- a/test/jqLiteSpec.js
+++ b/test/jqLiteSpec.js
@@ -83,6 +83,33 @@ describe('jqLite', function(){
});
+ describe('inheritedData', function() {
+
+ it('should retrieve data attached to the current element', function() {
+ var element = jqLite('<i>foo</i>');
+ element.data('myData', 'abc');
+ expect(element.inheritedData('myData')).toBe('abc');
+ dealoc(element);
+ });
+
+
+ it('should walk up the dom to find data', function() {
+ var element = jqLite('<ul><li><p><b>deep deep</b><p></li></ul>');
+ var deepChild = jqLite(element[0].getElementsByTagName('b')[0]);
+ element.data('myData', 'abc');
+ expect(deepChild.inheritedData('myData')).toBe('abc');
+ dealoc(element);
+ });
+
+
+ it('should return undefined when no data was found', function() {
+ var element = jqLite('<ul><li><p><b>deep deep</b><p></li></ul>');
+ var deepChild = jqLite(element[0].getElementsByTagName('b')[0]);
+ expect(deepChild.inheritedData('myData')).toBeFalsy();
+ dealoc(element);
+ });
+ });
+
describe('scope', function() {
it('should retrieve scope attached to the current element', function() {
var element = jqLite('<i>foo</i>');