Skip to content

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

@NPavie

Description

@NPavie

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions