diff options
| author | Misko Hevery | 2011-07-26 12:06:14 -0700 |
|---|---|---|
| committer | Igor Minar | 2011-10-11 10:53:05 -0700 |
| commit | bda2bba2be7a52bf39fb1b257b6363edc7b71173 (patch) | |
| tree | 70de396d785f7632377391d3463032826aa2d4c9 /test/jqLiteSpec.js | |
| parent | ca08c004c893310ed9b3b4a5d2a4d16314eaa677 (diff) | |
| download | angular.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.js | 27 |
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>'); |
