Skip to content

layout: style attributes are remembered per source tree, background no longer adds background-image:none - #3682

Merged
BaseMax merged 2 commits into
mainfrom
fix/web-css-en-fa
Nov 19, 2026
Merged

BaseMax merged 2 commits into
mainfrom
fix/web-css-en-fa

Conversation

@BaseMax

@BaseMax BaseMax commented Nov 19, 2026

Copy link
Copy Markdown
Member

Two bugs in the page style output.

  1. The page and its Persian twin gave different CSS when built in one process (salam page build en.salam fa.salam, and probably the LSP, serve, repl and editor): the semantic pass remembered each validated style attribute in global vectors keyed by AST node id alone, never cleared, and looked up the first entry with a matching id. A second page has different attributes at the same node ids, so its padding (فاصله داخلی) found the first page's background entry: the background came out twice and the padding never appeared. Each at.Ast now has a unique uid assigned in NewAst, stored with every remembered entry, and the lookups take the AST and match on it. Clearing the vectors at the start of Run would not work because the layout generator runs Run again on a second AST during codegen.

  2. background = "blue" emitted background-image:none next to background-color. The std style writer does that on purpose so a state rule can reset a gradient from the base rule, but with a plain color nothing sets an image and the global :where reset already gives background-image:none. The compiler now strips it from an element's rules unless a rule of that element sets a real image or gradient, or the element has a user class or dynamic class/style.

Before (Persian, English page built first): .a { background-color:#0000ff;background-image:none;background-color:#0000ff;background-image:none;color:#ffffff; } .b { padding:20px; }
After: .a { background-color:#0000ff;color:#ffffff;padding:24px; } .b { padding:20px; }

Tests: en/fa twins parity_header_box and parity_pairs (margin, border, font size, width, height, text align, padding) under page/style, and the fixtures that expected the image reset are updated. page/style with the fixed compiler: 591 passed, 99 failed, against 589 and 101 on main; the 99 are the same pre-existing list (old fixtures that expect the spaced prop: value format). The multi page collision has no harness test because the runner builds one file at a time.

Found, not fixed: فاصله بیرونی gives E112 on a page element (page margin knows فضا and حاشیه), and display with a Persian enum word fails E018 with an English only suggestion list.

…only background no longer carries background-image:none

A second page built in the same run read the first page's remembered style entries because they were keyed by node id alone, which lost the Persian header padding and repeated its background. Entries now carry the id of their source tree. The image reset is dropped from an element's rules when nothing on that element sets an image.
@BaseMax
BaseMax requested a review from a team as a code owner November 19, 2026 17:26
@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3dc4b8cb-58ad-4902-969c-086783ace0e7
Commits

Reviewing files that changed from the base of the PR and between 387f040 and 4865b26.

Files selected for processing: 17

  • compiler/ast.salam
  • compiler/sal_layout/layout_gen_element.salam
  • compiler/semantic/sema_layout_check.salam
  • compiler/semantic/sema_layout_style.salam
  • tests/en/page/style/css_property.salam
  • tests/en/page/style/edge_state_prefixes.salam
  • tests/en/page/style/parity_header_box.salam
  • tests/en/page/style/parity_pairs.salam
  • tests/en/page/style/prop_background_color.salam
  • tests/en/page/style/pseudo_space_prefix.salam
  • tests/en/page/style/state_blocks.salam
  • tests/en/page/style/value_lists.salam
  • tests/fa/page/style/edge_state_prefixes.salam
  • tests/fa/page/style/parity_header_box.salam
  • tests/fa/page/style/parity_pairs.salam
  • tests/fa/page/style/prop_background_color.salam
  • tests/fa/page/style/state_blocks.salam
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown
Contributor
sha=4865b26ad78cf0f07cbd2052720d6358f83974d3

🤖 Salam AI review

Verdict: 🛠️ Changes needed before merging

commit 4865b26 · 17 files · +180 −27 · model salam

Summary

This pull request scopes remembered layout style attributes to a unique AST uid to prevent cross-page collisions in one process and strips redundant background-image:none from color-only backgrounds. The core fixes are well targeted and covered by updated expectations plus new en/fa parity tests, but there are a couple of concrete issues to address before merge.

What changed

  • compiler/ast.salam assigns a unique uid to each Ast; compiler/semantic/sema_layout_style.salam stores and matches this uid for remembered style attributes, and sema_layout_check.salam / layout_gen_element.salam are updated to pass the AST through the lookups.
  • layout_gen_element.salam adds lo_drop_bg_none to remove background-image:none when no real image/gradient or dynamic/user styling requires the reset.
  • Existing style tests are adjusted, and new en/fa parity fixtures (parity_header_box, parity_pairs) are added.

Review

  • compiler/sal_layout/layout_gen_element.salam (end of lo_collect_attrs): lo_drop_bg_none(la) runs after the inline style attribute is built and emitted from st. If any element is rendered with an inline style, it would still include background-image:none while only la.css/state fields are cleaned. If class-based output consumes those fields after collection this may be fine, but can you confirm the inline path is unaffected or move the drop before computing/emitting st?
  • tests/en/page/style/parity_header_box.salam:1, tests/en/page/style/parity_pairs.salam:1, tests/fa/page/style/parity_header_box.salam:1, tests/fa/page/style/parity_pairs.salam:1: the added Salam files start with a block comment rather than the required language marker. Please add // lang: en or // زبان: فارسی as the first line, as appropriate.

Tests

The new parity fixtures and expectation updates align with the described bugs and fixes. The PR notes page/style results of 591 passed / 99 failed versus 589 / 101 on main, with the remaining failures described as pre-existing; I did not run tests. No harness coverage is added for the multi-page-in-one-process collision because the runner builds one file at a time, as noted.

Risks

Remembered style entries remain in process-global vectors for the lifetime of the process (now keyed by AST uid), so long-lived sessions such as LSP/serve/repl may continue accumulating entries. The reported unfixed issues (فاصله بیرونی / Persian display enum handling) remain out of scope.


⚠️ This review was written automatically by an AI and may contain mistakes. It is a helper for maintainers, not a replacement for a human review: check the code yourself before merging.

@BaseMax
BaseMax merged commit 8ffc8a2 into main Nov 19, 2026
22 checks passed
@BaseMax
BaseMax deleted the fix/web-css-en-fa branch November 19, 2026 17:44
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