Skip to content

v2: canonicalize — namespace prefix re-declaration on child elements #55

Description

@MeatPopSci1972

Context

Discovered during Issue #51 follow-up review. Filed as a known limitation of the v1 canonicalizer.

Problem

When an SVG uses namespace-prefixed attributes on child elements (e.g. xlink:href on <use>), @xmldom/xmldom may re-declare namespace prefixes on child elements during serialization. This can produce non-canonical output for SVGs that use xmlns:xlink or other namespace prefixes beyond the base xmlns.

Current behavior (locked in by test)

The xlink:href probe in the existing test suite shows that xmlns:xlink currently appears exactly once (on root) with no child re-declaration — this is the stable case. However, more complex namespace usage (multiple prefixed attributes, deeply nested elements, mixed namespace scopes) has not been tested and may produce redundant xmlns: declarations.

Why deferred

  • SequenceForge's own SVG output does not use xlink: or other namespace prefixes — this is a future-consumer concern
  • Fixing this requires either a post-serialization namespace deduplication pass or replacing XMLSerializer with a custom serializer
  • The v1 canonicalizer is correct for all current SequenceForge SVG output

Gate condition for this issue

The existing known-limitation test in sequence-builder.canonicalize.test.js must be updated (or extended) when this is fixed. The test name is:

Known limitation: xlink namespace on use element canonicalizes without redundant re-declaration

Out of scope here

  • d, viewBox, transform, points numeric normalization (separate v2 issue)
  • Default attribute elision

References

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions