diff --git a/src/zepto.js b/src/zepto.js index 0604dd08e..63ae76c95 100644 --- a/src/zepto.js +++ b/src/zepto.js @@ -174,7 +174,7 @@ var Zepto = (function() { else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false); return this; }, - get: function(idx){ return idx === undefined ? this : this[idx] }, + get: function(idx){ return idx === undefined ? slice.call(this) : this[idx] }, size: function(){ return this.length }, remove: function () { return this.each(function () { diff --git a/test/zepto.html b/test/zepto.html index ed0802330..b2f12e435 100644 --- a/test/zepto.html +++ b/test/zepto.html @@ -328,6 +328,21 @@

Zepto DOM unit tests

t.assertEqualCollection(['a', 'b', 'c'], zepto); }, + testGetWithoutIndex: function(t){ + var zepto = $('#find1 .findme'); + var array = zepto.get(); + t.assertFalse(zepto === array); + t.assertTrue($.isArray(array)); + t.assertTrue(array.pop === ([]).pop); + }, + + testGetWithIndex: function(t){ + var zepto = $('#find1 .findme'); + var outofbounds = zepto.get(zepto.size()); + t.assertEqual(zepto.get(0), zepto[0]); + t.assertUndefined(outofbounds); + }, + testSize: function(t){ t.assertEqual(4, $('#find1 .findme').size()); },