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
While doing a custom formatter with the lib (which I found really great by the way), i noticed something that caused me some trouble :
While formatting an XML file, I want the file content to remain as close to source as possible, including possible syntax errors that the user would be in charge to correct.
When testing a wrongly formatted file with the parser in non-strict mode, I realised that the parser was raising onclosetag event when closing tags were not existing, without notifying me in some way that the closing tag in question was "virtual" as in "does not exists in document".
As a result, i was wrongfully creating closing tag at the wrong place while formatting.
The simplest option to avoid this I think would be for the onclosetag event to be emitted with a "virtual" boolean value indicating that the onclosetag was sent while no closing tag was present in the document.
(With some slight modification, i think it can be done without breaking existing code base. I have prepared something for it in a modified version of the sax-js for the formatted i was working on, i'll be making a PR for fix proposal when I have finished creating some tests for it)
The text was updated successfully, but these errors were encountered:
NPavie
added a commit
to NPavie/sax-js
that referenced
this issue
Nov 15, 2023
fixisaacs#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
While doing a custom formatter with the lib (which I found really great by the way), i noticed something that caused me some trouble :
While formatting an XML file, I want the file content to remain as close to source as possible, including possible syntax errors that the user would be in charge to correct.
When testing a wrongly formatted file with the parser in non-strict mode, I realised that the parser was raising onclosetag event when closing tags were not existing, without notifying me in some way that the closing tag in question was "virtual" as in "does not exists in document".
As a result, i was wrongfully creating closing tag at the wrong place while formatting.
The simplest option to avoid this I think would be for the onclosetag event to be emitted with a "virtual" boolean value indicating that the onclosetag was sent while no closing tag was present in the document.
(With some slight modification, i think it can be done without breaking existing code base. I have prepared something for it in a modified version of the sax-js for the formatted i was working on, i'll be making a PR for fix proposal when I have finished creating some tests for it)
The text was updated successfully, but these errors were encountered: