diff stanza.js @ 106:c06ec02217ee

many changes
author Sonny Piers <sonny@fastmail.net>
date Tue, 26 Jun 2012 12:02:14 +0200
parents 1e6d2ca2daae
children 704ce44c1a22
line wrap: on
line diff
old mode 100644
new mode 100755
--- a/stanza.js
+++ b/stanza.js
@@ -23,16 +23,13 @@
  * @memberOf Lightstring
  */
 Lightstring.Stanza = function(aStanza) {
-  if (typeof aStanza === 'string') {
-    this.XML = aStanza;
-    this.DOM = Lightstring.XML2DOM(this.XML);
-  }
-  else if (aStanza instanceof Element) {
-    this.DOM = aStanza;
-    this.XML = Lightstring.DOM2XML(this.DOM);
-  }
-  //ToDo error ?
-  else {
-    return null;
-  }
+  if (typeof aStanza === 'string')
+    this.el = Lightstring.parse(aStanza);
+  else if (aStanza instanceof Element)
+    this.el = aStanza;
+  else
+    this.el = null;//TODO error
 };
+Lightstring.Stanza.prototype.toString = function() {
+  return Lightstring.serialize(this.el);
+};
\ No newline at end of file