[Pkg-javascript-commits] [ltx] 251/469: added filter method
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 13:03:09 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository ltx.
commit fac9f00977bd237f4474b59554280abc8f60148b
Author: Markus Kohlhase <mail at markus-kohlhase.de>
Date: Mon Dec 31 01:38:04 2012 +0100
added filter method
---
lib/element.js | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/lib/element.js b/lib/element.js
index 7189847..9ee2fcb 100644
--- a/lib/element.js
+++ b/lib/element.js
@@ -108,6 +108,22 @@ Element.prototype.getChildrenByAttr = function(attr, val, xmlns, recursive) {
return result;
};
+Element.prototype.getChildrenByFilter = function(filter, recursive) {
+ var result = [];
+ for(var i = 0; i < this.children.length; i++) {
+ var child = this.children[i];
+ if (filter(child))
+ result.push(child);
+ if (recursive && child.getChildrenByFilter){
+ result.push(child.getChildrenByFilter(filter, true));
+ }
+ }
+ if (recursive){
+ result = [].concat.apply([], result);
+ }
+ return result;
+};
+
Element.prototype.getText = function() {
var text = "";
for(var i = 0; i < this.children.length; i++) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git
More information about the Pkg-javascript-commits
mailing list