Bring verified local inline JSON updates to main - #19
Merged
Merged
Conversation
JSON cannot represent undefined, functions or symbols, and JSON.stringify treats all three identically: omitted from an object, null in an array. That conflates a representable absence with an unsupported type, and it drops nested data silently, so embedded page data can be missing fields the author expected. - Top-level failures now name the category rather than sharing one message. A function replacer keeps the generic message, because the original value no longer explains the result. - Add the optional onUnsupported option. 'omit' is the default and preserves current behaviour exactly; 'throw' reports the value and its path (user.email, items[2].name) instead of dropping it. - Values are inspected after toJSON and after a function replacer, so a value that becomes unrepresentable is reported too. - onUnsupported: 'throw' rejects an array replacer, which omits properties by design and would give the combination a confusing meaning. The serializer API and all existing behaviour are unchanged.
Existing tests round-trip through JSON.parse, which never exercises the reason this package escapes < in the first place. Add a fixture that implements the HTML raw-text end-tag rule -- </script followed by whitespace, / or > -- and reads the value back out of a rendered page. Covers nested Unicode (combining marks, astral planes, RTL scripts, U+2028 and U+2029) and confirms a hostile payload cannot terminate its containing script element or disturb the markup after it. The fixture is a test helper implementing one spec rule, not a general HTML parser, and is not shipped in the package.
Add a supported-values table and an onUnsupported section covering the silent data loss that the default behaviour inherits from JSON.stringify, and record the changes in the changelog.
edilec
approved these changes
Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This replays eight locally verified commits after the existing public main history. Their file trees, messages, author identities, and original dates are preserved. The final tree matches the verified local checkout, and the offline check passed. This uses the required pull-request path; no public history is force-rewritten.