[Pkg-javascript-commits] [ltx] 10/469: xml: getName() without element prefix
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 13:00:51 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 83e953aaf9eafe2e5c94cae4cb557f03167faca8
Author: Astro <astro at spaceboyz.net>
Date: Thu May 27 01:34:59 2010 +0200
xml: getName() without element prefix
---
lib/xmpp/xml.js | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/lib/xmpp/xml.js b/lib/xmpp/xml.js
index 335f513..2b8a694 100644
--- a/lib/xmpp/xml.js
+++ b/lib/xmpp/xml.js
@@ -11,6 +11,19 @@ function Element(name, attrs) {
/*** Accessors ***/
+Element.prototype.is = function(name, xmlns) {
+ return this.getName() == name &&
+ (!xmlns || this.getNS() == xmlns);
+};
+
+/* without prefix */
+Element.prototype.getName = function() {
+ if (this.name.indexOf(":") >= 0)
+ return this.name.substr(this.name.indexOf(":") + 1);
+ else
+ return this.name;
+};
+
Element.prototype.getNS = function() {
if (this.name.indexOf(":") >= 0) {
var prefix = this.name.substr(0, this.name.indexOf(":"));
@@ -45,7 +58,7 @@ Element.prototype.getChild = function(name, xmlns) {
Element.prototype.getChildren = function(name, xmlns) {
var result = [];
this.children.forEach(function(child) {
- if (child.name == name &&
+ if (child.getName() == name &&
(!xmlns || child.getNS() == xmlns))
result.push(child);
});
--
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