isaacs / sax-js

A sax style parser for JS
Other
1.09k stars 325 forks source link

feat: add explicit option for unquoted attribute values #268

Closed SethFalco closed 3 months ago

SethFalco commented 7 months ago

Would it be alright to make an explicit parser option for handling unquoted attribute values?

This is a backward-compatible change that allows users to specify how they want unquoted attributes handled. If it isn't specified, we fall back to the original behavior by following strict/loose mode.

Regression Tests

Similarly to #267, I've run the regression test script from #266, and can confirm it passes.

Alternatives

It looks like downstream projects that want to use strict mode, yet also want to allow unquoted attributes, can safely throw away error events with the message Unquoted attribute value if they want this behavior. We could do this instead, if introducing an explicit option upstream is undesirable.

Not certain if that way of handling it could be problematic or have side effects, so I thought this change would be safer.

Related