Replace the `* 9999999px` multiplier trick in NodeGap with CSS container style queries
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- css, typescript
- Domain
- frontend
Research direction
Start with NodeGap.svelte and NodeCaret.svelte, locating the positioning rules that use the 9999999px and 99999px sentinels. Replace only the row/column branch selection with style-query branches for --row: 0 and --row: 1, leaving anchor fallback values out of scope. Done means the consumer-facing --row API remains unchanged and both axes retain their positioning behavior, including changes under media or container queries.
Written by the indexing model from the issue text.
Description
Problem
NodeGap.svelte and NodeCaret.svelte switch between row and column positioning by reading --row (0 or 1) and using a multiplier-inside-min() trick:
top: min(
calc(var(--_s-b) + var(--_R) * 9999999px),
calc(var(--_mid) + var(--_R) * 9999999px),
calc(var(--_s-t) + var(--_C) * 9999999px)
);
Adding 9999999px to a branch makes it lose min() — effectively disabling the wrong-axis branch. The same trick repeats throughout positioning rules.
This works but has some downsides:
- Hard ceiling at ~10 million px. Documents (or scroll containers) taller than the sentinel produce wrong positioning. We cannot go beyond this because of css limitations in e.g. blink browser (but would need to be tested).
- Hard to read. Every coordinate carries
+ var(--_R) * 9999999pxor+ var(--_C) * 9999999px. Intent is buried in arithmetic. - Fragile. Changing the sentinel requires updating every site (currently
9999999pxis paired with a99999pxsentinel elsewhere — easy to drift. Had lots of headaches because of this already).
Proposal
Use CSS container style queries to route positioning rules by --row value. Each branch contains only the calculations relevant to its axis — no sentinels, no disable trick.
.positioned.gap-after:not(.last) .svedit-selectable {
/* shared declarations */
}
@container style(--row: 0) {
.positioned.gap-after:not(.last) .svedit-selectable {
top: min(calc(var(--_s-b)), var(--_mid));
bottom: min(calc(var(--_n-t)), var(--_mid));
/* … */
}
}
@container style(--row: 1) {
.positioned.gap-after:not(.last) .svedit-selectable {
left: min(calc(var(--_s-r)), var(--_mid));
right: min(calc(var(--_n-l)), var(--_mid));
/* … */
}
}
The consumer-facing API is unchanged: --row: 0 for vertical flow, --row: 1 for horizontal, declared on the node array or any ancestor. The multiplier trick disappears.
Why this works for cases the multiplier trick was protecting against
--row can change under media queries, container queries, or theme switches. Style queries re-evaluate just like any other matcher: when the consumer flips --row in a media query, the active branch swaps automatically. There is no static-axis assumption baked into the library.
Benefits
- No document-height ceiling.
- Positioning rules are readable in isolation — each branch reads as plain row or plain column code.
- Removes paired sentinels (
9999999px,99999px) and the implicit contract between them. - Slightly less work for the engine: fewer
anchor()resolutions per gap (only the active branch's anchors are evaluated).
Costs
- Browser support. Container style queries: Chrome/Edge 111+ (Mar 2023), Safari 18 (Sep 2024), Firefox not yet supported. Affects orientation correctness on Firefox until it ships; layout still renders, gaps and carets just position as if for the default axis.
Out of scope
- Anchor fallback values (
anchor(..., 9999999px)) used for orphan-anchor handling — those are a separate concern from the row/column branch-disable trick.
- Dominant language
- TypeScript
- Stars
- 691
- Forks
- 20
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from michael/svedit
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Similar issues
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/clickhouse-js#1293 ·
Maintainers usually reply within 1 day
-
area: middleware enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
agent/quality testing
Difficulty 1/5 Under an hour Newbie friendliness 95/100
Maintainers usually reply within 1 day
-
GitHub registry install via `gh` credentials rewrites `\u0000`–`\u001f` escapes in source files to `^@`–`^_`Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
juspay/agent-distro#203 ·
Maintainers usually reply within 1 day