Skip to content

Map the HTML presentational attributes per spec - #662

Open
latentharbor wants to merge 2 commits into
DioxusLabs:mainfrom
latentharbor:map-html-presentational-attributes
Open

Map the HTML presentational attributes per spec#662
latentharbor wants to merge 2 commits into
DioxusLabs:mainfrom
latentharbor:map-html-presentational-attributes

Conversation

@latentharbor

@latentharbor latentharbor commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Two commits reworking the legacy presentational-attribute mapping in blitz-dom.

Map the HTML dimension attributes per spec

The old parser was parse::<f32>() with any trailing unit peeled off, which

  • rejected valid values like 200in and 200 % (trailing garbage is ignored per spec),
  • accepted -200 and +200 (dimension values have no sign),
  • read 20.25e2 as 2025px — the rules for parsing dimension values have no exponent, so that is 20.25px followed by junk.

It also fills in the missing parts of the element table: width/height on the embedded elements (iframe, embed, video, object, img, marquee, input[type=image]) and the table elements (table, colgroup, col, tr, td, th, with the ignore-zero rules for cells and table width), and hspace/vspace mapping to the margin pairs.

Map border and the body margin attributes

  • border on img/object/input[type=image] follows the rules for parsing non-negative integers and maps to the four border widths plus border-style: solid on all four sides — width alone computes back to zero against the default border-style: none.
  • marginwidth/marginheight/topmargin/leftmargin on body map to the margins the HTML standard lists for them. Deliberately no rightmargin/bottommargin: the spec does not define them, and WPT body-margin-3a/3b assert they are ignored.

Validation

WPT via the in-tree runner:

  • html/rendering: three tests go FAIL→PASS — non-replaced-elements/tables/table-row-height.html, non-replaced-elements/the-hr-element-0/width.html, replaced-elements/attributes-for-embedded-content-and-images/img_border_percent.xhtml — with no other status changes.
  • css/css-display and css/css-tables: per-test statuses identical to main.

The body-margin and hspace/vspace mappings have no reftest signal in the runner (the WPT tests covering them are testharness.js-based, which the runner skips, and body-margin-1/2 crash on an unrelated pre-existing iframe issue). I verified those with throwaway local reftests (e.g. <body marginwidth=100 marginheight=30> against body { margin: 30px 100px }, and <img hspace=40 vspace=10> against margin: 10px 40px): all fail on main and pass with this change.

🤖 Generated with Claude Code

WPT results

No changes in test results compared to main.

Generated by the WPT workflow.

latentharbor and others added 2 commits August 9, 2026 15:49
The parser was parse::<f32>() with any trailing unit peeled off, which rejected
"200in" and "200 %", accepted "-200" and "+200", and read "20.25e2" as 2025px
-- the rules for parsing dimension values have no exponent, so that is 20.25px
followed by junk. Most of the element table was also missing.

Follows 'rules for parsing dimension values' and the presentational hints each
element actually maps.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
border on img/object/input[type=image] follows the rules for parsing
non-negative integers and maps to the four border widths plus
border-style: solid on all four sides -- width alone computes back to
zero against the default border-style of none.

marginwidth/marginheight/topmargin/leftmargin on body map to the margins
the HTML standard lists for them. There is deliberately no rightmargin
or bottommargin: the spec does not define them and WPT body-margin-3a/3b
assert they are ignored.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@latentharbor
latentharbor force-pushed the map-html-presentational-attributes branch from c80c5d0 to b216d43 Compare August 9, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant