Skip to content

Commit

Permalink
fix(onclosetag): notify virtual closing tags
Browse files Browse the repository at this point in the history
fix isaacs#262:
Emit a boolean value to indicate if the onclosetag event was sent
without the closing tag actually existing in the document.

Also:
- changed the event emitters function to take a variable arguments list
  • Loading branch information
NPavie committed Nov 15, 2023
1 parent b577600 commit 953da1e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/sax.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,13 +621,13 @@
// shorthand
S = sax.STATE

function emit (parser, event, data) {
parser[event] && parser[event](data)
function emit (parser, event, ...data) {
parser[event] && parser[event](...data)
}

function emitNode (parser, nodeType, data) {
function emitNode (parser, nodeType, ...data) {
if (parser.textNode) closeText(parser)
emit(parser, nodeType, data)
emit(parser, nodeType, ...data)
}

function closeText (parser) {
Expand Down Expand Up @@ -887,7 +887,7 @@
while (s-- > t) {
var tag = parser.tag = parser.tags.pop()
parser.tagName = parser.tag.name
emitNode(parser, 'onclosetag', parser.tagName)
emitNode(parser, 'onclosetag', parser.tagName, s > t)

var x = {}
for (var i in tag.ns) {
Expand Down

0 comments on commit 953da1e

Please sign in to comment.