Skip to content

Split facet-html-dom from facet-html (issue #1529) - #1580

Merged
fasterthanlime merged 1 commit into
mainfrom
split-html-dom-1529
Jan 3, 2026
Merged

Split facet-html-dom from facet-html (issue #1529)#1580
fasterthanlime merged 1 commit into
mainfrom
split-html-dom-1529

Conversation

@fasterthanlime

Copy link
Copy Markdown
Contributor

Summary

Splits the HTML DOM element types into a new facet-html-dom crate so they can properly use the #[facet(html::elements)] attribute namespace instead of falling back to #[facet(xml::elements)].

Fixes #1529

Changes

  • New crate facet-html-dom: Contains all typed HTML5 element definitions (Html, Head, Body, Div, Span, etc.)
  • DOM types now use canonical html:: attributes:
    • #[facet(html::elements)] for child element collections
    • #[facet(html::attribute)] for HTML attributes
    • #[facet(html::text)] for text content
  • Updated facet-html: Now contains only the parser, serializer, and attribute grammar
  • Updated all tests to import from facet_html_dom directly

Why the split?

Due to Rust limitation rust-lang/rust#52234, macro-exported attributes cannot be referenced by absolute path from within the same crate. By moving DOM types to a separate crate that depends on facet-html, they can properly use the html:: namespace.

Migration

Users should update imports:

// Before
use facet_html::elements::{Html, Div, P};

// After  
use facet_html_dom::{Html, Div, P};

Test plan

  • All 2482 existing tests pass
  • DOM types correctly use html:: attributes (129 occurrences, 0 xml:: references)

@github-actions github-actions Bot added ⚙️ core facet-core crate, core types and traits ✨ enhancement New feature or request 🔵 json facet-json crate, JSON serialization/deserialization labels Jan 3, 2026
@github-actions github-actions Bot added the 📜 derive Related to the derive macro label Jan 3, 2026
Due to Rust limitation rust-lang/rust#52234, macro-exported attributes
cannot be referenced from the same crate. This meant facet-html's DOM
types had to use `#[facet(xml::elements)]` instead of `#[facet(html::elements)]`.

This commit splits the DOM types into a new `facet-html-dom` crate that
depends on `facet-html`, allowing proper use of the `html::` namespace:

- Created `facet-html-dom` crate with all HTML element types
- DOM types now use `#[facet(html::elements)]`, `#[facet(html::attribute)]`,
  and `#[facet(html::text)]` instead of the xml:: equivalents
- Updated facet-html to remove the elements module
- Updated all tests to use `facet_html_dom` directly

Users should now use `facet_html_dom::{Html, Div, ...}` for typed HTML elements.
@github-actions github-actions Bot added the 🐪 yaml facet-yaml crate, YAML serialization/deserialization label Jan 3, 2026
@fasterthanlime
fasterthanlime added this pull request to the merge queue Jan 3, 2026
Merged via the queue into main with commit 24e7287 Jan 3, 2026
17 checks passed
@fasterthanlime
fasterthanlime deleted the split-html-dom-1529 branch January 3, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚙️ core facet-core crate, core types and traits 📜 derive Related to the derive macro ✨ enhancement New feature or request 🔵 json facet-json crate, JSON serialization/deserialization 🐪 yaml facet-yaml crate, YAML serialization/deserialization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider splitting facet-format-html-dom from facet-format-html

1 participant