Skip to content

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

Open
@inverted-capital

Description

@inverted-capital

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Participants

      @inverted-capital

      Issue actions

        xml.stringify( `obj` ) should not alter `obj` · Issue #94 · lowlighter/libs