Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.parser.on('startElement', (name, attrs) => {
if (!self.element) {
self.emit('startElement', name, attrs)
self.emit('start', new Element(name, attrs))
}
// TODO: refuse anything but
if (!self.element && (name === 'stream:stream')) {
self.emit('streamStart', attrs)
} else {
let child
if (!self.element) { // eslint-disable-line no-negated-condition
/* A new stanza */
child = new Stanza(name, attrs)
self.element = child
/* For maxStanzaSize enforcement */
self.bytesParsedOnStanzaBegin = self.bytesParsed
} else {
/* A child element of a stanza */
child = new ElementInterface(name, attrs)
self.element = self.element.cnode(child)
}
}
})