Created
December 10, 2010 21:13
-
-
Save jashkenas/736830 to your computer and use it in GitHub Desktop.
Some of the first few functions from: https://github.com/madrobby/zepto/blob/master/src/zepto.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn = { | |
remove: function() { | |
return this.each(function(el) { | |
return el.parentNode.removeChild(el); | |
}); | |
}, | |
each: function(callback) { | |
this.dom.forEach(callback); | |
return this; | |
}, | |
filter: function(selector) { | |
return $(this.dom.filter(function(element) { | |
return $$(element.parentNode, selector).indexOf(element) >= 0; | |
})); | |
}, | |
pluck: function(property) { | |
return this.dom.map(function(element) { | |
return element[property]; | |
}); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn = | |
remove: -> | |
@each (el) -> el.parentNode.removeChild el | |
each: (callback) -> | |
@dom.forEach callback | |
this | |
filter: (selector) -> | |
$ @dom.filter (element) -> | |
$$(element.parentNode, selector).indexOf(element) >= 0 | |
pluck: (property) -> | |
@dom.map (element) -> element[property] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn = { | |
remove: function() { | |
return this.each(function(el){ el.parentNode.removeChild(el) }); | |
}, | |
each: function(callback) { | |
this.dom.forEach(callback); | |
return this; | |
}, | |
filter: function(selector) { | |
return $(this.dom.filter(function(element){ | |
return $$(element.parentNode, selector).indexOf(element) >= 0; | |
})); | |
}, | |
pluck: function(property) { | |
return this.dom.map(function(element){ return element[property] }); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment