Skip to content

Commit

Permalink
remove fn.compact() method
Browse files Browse the repository at this point in the history
It's useless. There is no way a Zepto collection can contain
`null` or `undefined` in the first place.
  • Loading branch information
mislav committed Dec 28, 2010
1 parent 54a05bb commit dbe33a2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
3 changes: 0 additions & 3 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ Context and .find calls are equivalent:
return property for each element
e.g. pluck('innerHTML') returns an array of all innerHTML properties of all elements found

compact():
remove all null or undefined elements from list of elements found

anim(transform, opacity, duration):
use -webkit-transform/opacity and do an animation

Expand Down
5 changes: 2 additions & 3 deletions src/zepto.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ var Zepto = (function() {
else {
var dom;
if (selector instanceof Z) dom = selector.dom;
else if (selector instanceof Array) dom = selector;
else if (selector instanceof Array) dom = compact(selector);
else if (selector instanceof Element || selector === window) dom = [selector];
else if (fragmentRE.test(selector)) dom = fragment(selector);
else dom = $$(document, selector);

return new Z(compact(dom), selector);
return new Z(dom, selector);
}
}

Expand All @@ -47,7 +47,6 @@ var Zepto = (function() {
ready: function(callback){
document.addEventListener('DOMContentLoaded', callback, false); return this;
},
compact: function(){ this.dom = compact(this.dom); return this },
get: function(idx){ return idx === undefined ? this.dom : this.dom[idx] },
size: function(){ return this.length },
remove: function(){
Expand Down
8 changes: 0 additions & 8 deletions test/zepto.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,6 @@ <h1>Zepto DOM unit tests</h1>
t.assertLength(0, $('nonexistent').last());
},

testCompact: function(t){
var nodes = $('p');
nodes.dom = [nodes.get(0), null, undefined, nodes.get(0)];
nodes.compact();
t.assertLength(2, nodes);
t.assertEqual('PP', nodes.pluck('tagName').join(''));
},

testPluck: function(t){
t.assertEqual('H1DIVDIV', $('h1,div.htmltest').pluck('tagName').join(''));
},
Expand Down

0 comments on commit dbe33a2

Please sign in to comment.