comparison 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
comparison
equal deleted inserted replaced
105:fb50311997b5 106:c06ec02217ee
21 * @constructor Creates a new Stanza object. 21 * @constructor Creates a new Stanza object.
22 * @param {String|Object} [aStanza] The XML or DOM content of the stanza 22 * @param {String|Object} [aStanza] The XML or DOM content of the stanza
23 * @memberOf Lightstring 23 * @memberOf Lightstring
24 */ 24 */
25 Lightstring.Stanza = function(aStanza) { 25 Lightstring.Stanza = function(aStanza) {
26 if (typeof aStanza === 'string') { 26 if (typeof aStanza === 'string')
27 this.XML = aStanza; 27 this.el = Lightstring.parse(aStanza);
28 this.DOM = Lightstring.XML2DOM(this.XML); 28 else if (aStanza instanceof Element)
29 } 29 this.el = aStanza;
30 else if (aStanza instanceof Element) { 30 else
31 this.DOM = aStanza; 31 this.el = null;//TODO error
32 this.XML = Lightstring.DOM2XML(this.DOM);
33 }
34 //ToDo error ?
35 else {
36 return null;
37 }
38 }; 32 };
33 Lightstring.Stanza.prototype.toString = function() {
34 return Lightstring.serialize(this.el);
35 };