Skip to content

docs(API): specify behaviour of SetAttributes edits with attributesNS #30

@ca-d

Description

@ca-d

API.md does not currently specify the exact behaviour expected when commiting a SetAttributes edit with some attributesNS in it. The documentation might give the reader the impression that we will be simply calling element.setAttribute(...) and element.setAttributeNS(...) repeatedly.

However, our current implementation at @OpenEnergyTools/xml-lib tries to be a bit smarter and automatically handle namespace prefixes if the user tries to set an attribute without one in attributesNS. This "smarter" behaviour is error-prone (there might be clashes when guessing unique prefix strings) and will likely become a bit of a foot-gun.

I therefore propose that we move away from the "smart" behaviour to the expected behaviour of just calling element.setAttributeNS for each attribute listed in attributesNS and let the creator of the Edit bear responsibility for choosing and adding appropriate namespace prefixes as needed. Then we could explicitly advertise that behaviour within API.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions