You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the documentation, the parser object property "tag" reflects "The current tag being dealt with."
This does not work in all cases. See the following test:
import sax from "sax";
test("parser.tag.name should be to current element in ontext", () => {
const parser = sax.parser(true);
let currentElement: string[] = []
parser.onopentag = (node) => { currentElement.push(node.name); };
parser.onclosetag = (node) => { currentElement.pop(); };
parser.ontext = (text) => {
expect(parser.tag.name + " - " + text).toBe(currentElement[currentElement.length-1]+ " - " + text);
}
parser.write('<some><sub>Text<b>bold</b></sub></some>').close();
});
IMHO this is a bug. It seems as if the parser already detects the opening tag after the text, which also means the end of the text. But this following tag must not be the tag when ontext is called. It is weird that the parser's tag contains a new tag before onopentag (or onopentagstart) has been called. It actually means that ontext is called after the parser has found a new tag -- in other words it is called too late (from a client perspective)!
The text was updated successfully, but these errors were encountered:
According to the documentation, the parser object property "tag" reflects "The current tag being dealt with."
This does not work in all cases. See the following test:
This (Jest) test fails:
IMHO this is a bug. It seems as if the parser already detects the opening tag after the text, which also means the end of the text. But this following tag must not be the tag when ontext is called. It is weird that the parser's tag contains a new tag before onopentag (or onopentagstart) has been called. It actually means that ontext is called after the parser has found a new tag -- in other words it is called too late (from a client perspective)!
The text was updated successfully, but these errors were encountered: