Skip to content

BREAKING(xml): clean up public API#7233

Open
tomas-zijdemans wants to merge 4 commits into
denoland:mainfrom
tomas-zijdemans:xml-ready
Open

BREAKING(xml): clean up public API#7233
tomas-zijdemans wants to merge 4 commits into
denoland:mainfrom
tomas-zijdemans:xml-ready

Conversation

@tomas-zijdemans

Copy link
Copy Markdown
Contributor

Summary

Cleanup of the @std/xml public API in preparation for a future
stabilization proposal. The goal is to remove surface that should not be
stabilized and fix documentation that did not match actual behavior, so
the API that remains is the API we would commit to at 1.0.0.

Breaking changes

  • Remove unused exported types. The XmlEvent union and its event
    interfaces (XmlStartElementEvent, XmlEndElementEvent, XmlTextEvent,
    XmlCDataEvent, XmlCommentEvent, XmlProcessingInstructionEvent) and
    XmlAttribute were leftovers from a pre-callback event-object design and
    appeared in no public function signature. XmlTokenCallbacks is the
    tokenizer's internal contract and has moved to _tokenizer.ts.
  • Rename XmlDeclarationEvent to XmlDeclaration. It survives only as the
    type of XmlDocument.declaration, so the Event suffix was a misnomer.
  • XmlSyntaxError no longer appends at line 0, column 0 to messages
    when position tracking is disabled. line: 0 is documented as the
    sentinel for "position unknown".

Documentation fixes

  • XmlPosition.offset and XmlSyntaxError.offset are UTF-16 code-unit
    offsets into the input string, not byte offsets.
  • XmlElement.attributes is keyed by the raw qualified attribute name
    (e.g. xlink:href, xmlns:ns), not the local name.
  • XmlEventCallbacks.onDoctype now documents that it only fires when
    disallowDoctype: false is set; under the default, a DOCTYPE throws.

Tests

  • Public-level parseXmlStream() DOCTYPE tests: onDoctype receives name,
    public ID, and system ID; the default rejects DOCTYPE without invoking
    the callback (previously only covered at the internal tokenizer level).
  • Tests for the position-suffix behavior of XmlSyntaxError.

Test plan

  • deno task ok passes locally

This PR was developed with the assistance of an AI agent in Cursor; all
changes were reviewed and verified by me.


Note

Recreates #7206, which was closed automatically when I accidentally deleted the head fork. The branch is identical to the original PR head.

@github-actions github-actions Bot added the xml label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant