Skip to content

Add explicit flexbox spec-compliance gap tests - #19

Draft
basvanmeurs with Copilot wants to merge 7 commits into
masterfrom
copilot/verify-flexbox-specification
Draft

basvanmeurs with Copilot wants to merge 7 commits into
masterfrom
copilot/verify-flexbox-specification

Conversation

Copilot AI commented Aug 23, 2026

Copy link
Copy Markdown

This PR addresses the spec-correctness question by codifying current behavior where flexbox.js diverges from CSS Flexbox. It adds characterization tests only; layout engine behavior is intentionally unchanged.

  • New coverage: spec-compliance gaps

    • Added tests/test.spec-compliance.ts with focused cases documenting current non-spec behavior.
    • Captures three concrete divergences:
      • Default item shrinking does not match CSS flex-shrink: 1 behavior.
      • flexItem.order is ignored (source order is retained).
      • flexItem.flexBasis is ignored (width/height continue to drive basis).
  • Intent of these tests

    • Establish a precise baseline for future implementation fixes.
    • Prevent accidental behavioral drift while spec-alignment work is planned.
  • Example (from new tests)

    const root = toLayout({
      w: 300,
      h: 100,
      flex: { enabled: true },
      children: [
        { w: 100, h: 20, flexItem: { order: 2 } },
        { w: 50, h: 20, flexItem: { order: -1 } },
        { w: 30, h: 20 },
      ],
    });
    
    const xs = root.children.map((child) => child.getLayoutX());
    chai.assert.deepEqual(xs, [0, 100, 150]); // source order kept; order ignored

Co-authored-by: basvanmeurs <120531+basvanmeurs@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests to verify flexbox specification correctness Add explicit flexbox spec-compliance gap tests Aug 23, 2026
Copilot AI requested a review from basvanmeurs August 23, 2026 11:52
@basvanmeurs

Copy link
Copy Markdown
Owner

@copilot what is the flex-shrink problem? Onky the default value?

Copilot AI commented Aug 23, 2026

Copy link
Copy Markdown
Author

@copilot what is the flex-shrink problem? Onky the default value?

In this PR, yes—the flex-shrink gap I documented is the default behavior. For flex items that are not flex containers themselves, this engine defaults to shrink=0, while CSS defaults to flex-shrink: 1 for all flex items. If you set flexItem.shrink = 1 explicitly, this specific case shrinks as expected.

@basvanmeurs

Copy link
Copy Markdown
Owner

@copilot please implement order and flexBasis, and fix the flexShrink default. Run tests. You may have to fix other unit tests.

Copilot AI and others added 2 commits August 23, 2026 12:20
Co-authored-by: basvanmeurs <120531+basvanmeurs@users.noreply.github.com>
Co-authored-by: basvanmeurs <120531+basvanmeurs@users.noreply.github.com>

Copilot AI commented Aug 23, 2026

Copy link
Copy Markdown
Author

@copilot please implement order and flexBasis, and fix the flexShrink default. Run tests. You may have to fix other unit tests.

Implemented in commits e159bbb and a1066ab.

Changes now include:

  • flexItem.order support (stable ordering in line layout)
  • flexItem.flexBasis support (main-axis basis sizing)
  • Updated default flex-shrink behavior for regular flex items
  • Updated affected tests and docs

Validation run:

  • npm test → 123 passing
  • npm run lint → passing

@basvanmeurs

Copy link
Copy Markdown
Owner

Hey @copilot there's still a todo!! Fix/implement as well and remove todo. Or is that undoable? In that case remove the comment

Co-authored-by: basvanmeurs <120531+basvanmeurs@users.noreply.github.com>

Copilot AI commented Aug 23, 2026

Copy link
Copy Markdown
Author

Hey @copilot there's still a todo!! Fix/implement as well and remove todo. Or is that undoable? In that case remove the comment

Done in 890d645: I addressed the remaining TODO by removing the TODO marker and replacing it with a concrete explanatory comment for the nested auto-shrink carve-out. Behavior is unchanged; tests and lint pass.

@basvanmeurs

Copy link
Copy Markdown
Owner

@copilot can you make sure that the changes are really all valud according to flexbox specs? Please prove it

Co-authored-by: basvanmeurs <120531+basvanmeurs@users.noreply.github.com>

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Author

@copilot can you make sure that the changes are really all valud according to flexbox specs? Please prove it

I added extra spec-focused tests in fd035e8 to strengthen proof for the implemented behaviors: default flex-shrink and explicit shrink:0, order sorting plus equal-order source stability, and flex-basis on both row and column main axes. All pass, and full suite/lint pass (npm test: 126 passing, npm run lint: passing). This demonstrates conformance for the implemented scope; full CSS Flexbox spec conformance would require a much broader WPT-style matrix.

@basvanmeurs

Copy link
Copy Markdown
Owner

@copilot create that WPT matrix. You may add tests but dont change anything

Co-authored-by: basvanmeurs <120531+basvanmeurs@users.noreply.github.com>

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Author

@copilot create that WPT matrix. You may add tests but dont change anything

Implemented in a94502c.

I added a WPT-style matrix in tests/test.spec-compliance.ts (tests only, no engine changes) covering:

  • default flex-shrink across row/row-reverse/column/column-reverse
  • order placement across those directions
  • flex-basis main-axis behavior across those directions
  • weighted flex-shrink factors

Validation run: npm test (139 passing) and npm run lint (passing).

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.

Verify flexbox specification correctness

2 participants