[Pkg-javascript-commits] [ltx] 203/469: search recursively
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 13:02:58 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 f7075b8c22afadb3870fee9d97a62fc92b8f5a40
Author: Markus Kohlhase <mail at markus-kohlhase.de>
Date: Thu Dec 22 01:08:12 2011 +0100
search recursively
---
lib/element.js | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/element.js b/lib/element.js
index 010e358..b39f3d7 100644
--- a/lib/element.js
+++ b/lib/element.js
@@ -86,14 +86,14 @@ Element.prototype.getChildren = function(name, xmlns) {
/**
* xmlns can be null
**/
-Element.prototype.getChildByAttr = function(attr, val, xmlns) {
- return this.getChildrenByAttr(attr, val, xmlns)[0];
+Element.prototype.getChildByAttr = function(attr, val, xmlns, recursive) {
+ return this.getChildrenByAttr(attr, val, xmlns, recursive)[0];
};
/**
* xmlns can be null
**/
-Element.prototype.getChildrenByAttr = function(attr, val, xmlns) {
+Element.prototype.getChildrenByAttr = function(attr, val, xmlns, recursive) {
var result = [];
for(var i = 0; i < this.children.length; i++) {
var child = this.children[i];
@@ -101,6 +101,12 @@ Element.prototype.getChildrenByAttr = function(attr, val, xmlns) {
child.attrs[attr] == val &&
(!xmlns || child.getNS() == xmlns))
result.push(child);
+ if (recursive && child.getChildrenByAttr){
+ result.push(child.getChildrenByAttr(attr, val, xmlns, true));
+ }
+ }
+ if (recursive){
+ result = [].concat.apply([], result);
}
return result;
};
--
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