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

xml.stringify( obj ) should not alter obj #94

Open
inverted-capital opened this issue Jan 9, 2025 · 0 comments
Open

xml.stringify( obj ) should not alter obj #94

inverted-capital opened this issue Jan 9, 2025 · 0 comments

Comments

@inverted-capital
Copy link

inverted-capital commented Jan 9, 2025

If I do:

        const withRoot = Object.freeze({ [tagName]: json })
        const snippet = xml.stringify(withRoot)

And error will be thrown:

error: TypeError: Cannot add property ~name, object is not extensible
  ;(document as Record<PropertyKey, unknown>)["~name"] ??= "xml"
                                                      ^
    at xml_prolog (https://jsr.io/@libs/xml/6.0.4/stringify.ts:135:55)
    at Module.stringify (https://jsr.io/@libs/xml/6.0.4/stringify.ts:74:11)

In general, an operation to translate one object into another should not alter the source object.

(thank you for this library - it is the best xml parser out there)

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