Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify if onclosetag is sent for a non-existing closing tag #262

Open
NPavie opened this issue Nov 15, 2023 · 0 comments
Open

Notify if onclosetag is sent for a non-existing closing tag #262

NPavie opened this issue Nov 15, 2023 · 0 comments

Comments

@NPavie
Copy link

NPavie commented Nov 15, 2023

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)

NPavie added a commit to NPavie/sax-js that referenced this issue Nov 15, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant