Skip to content

fix: let no style, script or template stand at a frame's edge - #7543

Merged
leaf-agent merged 2 commits into
mainfrom
fix/issue-7531
Nov 28, 2026
Merged

leaf-agent merged 2 commits into
mainfrom
fix/issue-7531

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

The frame-edge rules in browser/styles/components/rendered.css trim the margin of a frame's first and last block, picking the first or last child that isn't chrome (.lf-ui), generated (data-lf-gen) or a popover. An element that never renders still counted, so a <style>, <script> or <template> beside the real edge block left that block's margin standing: 13px at each end of an author's frame. The rules now also skip script, style and template, as the group rule in browser/layouts.css already does. The specificity is unchanged, since :not() takes its most specific argument, which stays a class.

This is what broke test_each_sampled_focus_ring_is_shown_whole_in_its_surface after #7456. Playwright's style screenshot option appends an unmarked <style> to every shadow root while it captures. Inside lf-option's shadow root that <style> became the last child, so the slotted paragraph kept its bottom margin and every option below moved down 13px in the capture. #7456 made the ring reading sample a whole-window capture taken with that option (browser.screenshot), so the reading looked for each lower option's ring 13px above where the capture drew it. With the CSS fixed, #7456's whole-window reading stays as it is.

Verification

  • New test_an_element_that_never_renders_does_not_stand_at_a_frames_edge (tests/browser/test_render_options.py) fails on main with the frame leaves {'top': 13, 'bottom': 13} and passes with the change. It also checks that appending a <style> to an option's shadow root leaves the option's height unchanged.
  • The journey test fails on main with the issue's 16 faults over 42 samples and passes with the change (run by node id on Linux).
  • The other frame tests in test_render_options.py and test_render_gate.py pass, and so does tests/model/test_interact_layer.py.
  • uv run leaf-dev stills across every state against main: every crop is pixel-identical. The only differences are page-about, whose source listing prints the edited CSS, and frame noise in the video states. No shipped example has a never-rendering element beside a block at a frame's edge.

Closes #7531 — automated triage

The frame-edge rules in rendered.css trim the margin of a frame's first and
last block, picking that block as the first or last child that isn't chrome,
generated or a popover. An element that never renders counted as a block, so
a `<style>`, `<script>` or `<template>` beside the real edge block left that
block's margin standing: 13px at each edge of an author's frame.

Playwright's `style` screenshot option appends an unmarked `<style>` to every
shadow root while it captures. Inside `lf-option`'s root it became the last
child, the slotted paragraph kept its bottom margin, and every option below
moved down 13px in the capture. Since #7456 the ring reading samples a
whole-window capture taken with that option (`browser.screenshot`), so it read
each lower option's ring 13px from where the page measured it, failing
test_each_sampled_focus_ring_is_shown_whole_in_its_surface with 16 faults on
option lists. The rules now skip `script`, `style` and `template`, as
layouts.css's group rule already does.

The new browser test fails before the change (13px at each end of an author's
frame) and passes after; the ring journey test fails on main and passes with
the change.

Closes #7531
@leaf-agent
leaf-agent merged commit 392e31c into main Nov 28, 2026
7 checks passed
@leaf-agent
leaf-agent deleted the fix/issue-7531 branch November 28, 2026 19:08
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.

test_each_sampled_focus_ring_is_shown_whole_in_its_surface: 16 ring faults on option lists since #7456's whole-window capture

1 participant