[Pkg-javascript-commits] [ltx] 245/469: doc
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 13:03:08 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 14889c48115f68888b2a31f373af5478063bcdb8
Author: Markus Kohlhase <mail at markus-kohlhase.de>
Date: Sat Jun 9 14:13:26 2012 +0200
doc
---
README.markdown | 4 ++--
lib/element.js | 11 ++++-------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/README.markdown b/README.markdown
index 2886ec1..38ab1f4 100644
--- a/README.markdown
+++ b/README.markdown
@@ -47,8 +47,8 @@ Refer to `lib/parse.js` for the interface.
* `findNS(prefix?)`: search for xmlns of a prefix upwards
* `getChild(name, xmlns?)`: find first child
* `getChildren(name, xmlns?)`: find all children
-* `getChildByAttr(attr, value, xmlns?)`: find first child by a specific attribute
-* `getChildrenByAttr(attr, value, xmlns?)`: find all children by a specific attribute
+* `getChildByAttr(attr, value, xmlns?, recursive?)`: find first child by a specific attribute
+* `getChildrenByAttr(attr, value, xmlns?, recursive?)`: find all children by a specific attribute
* `getText()`: appends all text nodes recursively
* `getChildText(name)`: a child's text contents
* `root()`: uppermost parent in the tree
diff --git a/lib/element.js b/lib/element.js
index e9d7583..02a786f 100644
--- a/lib/element.js
+++ b/lib/element.js
@@ -84,14 +84,14 @@ Element.prototype.getChildren = function(name, xmlns) {
};
/**
- * xmlns can be null
+ * xmlns and recursive can be null
**/
Element.prototype.getChildByAttr = function(attr, val, xmlns, recursive) {
return this.getChildrenByAttr(attr, val, xmlns, recursive)[0];
};
/**
- * xmlns can be null
+ * xmlns and recursive can be null
**/
Element.prototype.getChildrenByAttr = function(attr, val, xmlns, recursive) {
var result = [];
@@ -101,13 +101,10 @@ Element.prototype.getChildrenByAttr = function(attr, val, xmlns, recursive) {
child.attrs[attr] == val &&
(!xmlns || child.getNS() == xmlns))
result.push(child);
- if (recursive && child.getChildrenByAttr){
+ if (recursive && child.getChildrenByAttr)
result.push(child.getChildrenByAttr(attr, val, xmlns, true));
- }
- }
- if (recursive){
- result = [].concat.apply([], result);
}
+ 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