nslot and ncc wrappers change the DOM tree with display:contents

Open
#722 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
56/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
frontend, testing

Research direction

Start by comparing the server-rendered and client-rendered DOM in the layout and island unit tests, focusing on nexy/modules/compiler/generator/logic.py and nexy/modules/compiler/frontend_templates.py. Investigate how the <slot> and <ncc> wrappers affect child selectors and hydration attributes, and establish whether the wrappers can be removed without changing the client runtime contract. Done means wrapper-free selectors produce the same computed styles in both rendering modes, the hydration data remains available to the client, and the existing layout and island tests pass.

Written by the indexing model from the issue text.

Description

Problem

nslot and ncc are rendered as real elements with display: contents:
nexy/modules/compiler/generator/logic.py:19 wraps layout children in
<nslot style='display:contents;'>, and
nexy/modules/compiler/frontend_templates.py:34 puts display: contents; on <ncc>.

Neither element creates a box, but both create a node in the DOM tree. Selectors that cross a
layout or island boundary, such as >, :first-child, :nth-child, grid and flex item
selectors, see a different tree in the server HTML than in a fully client render. Scripts that
walk children meet the same node.

Change to make

Measure the difference first with a focused test, then carry the mount data without inserting an
element into the layout tree, or give the wrappers a stable role and document the tree they
create. The hydration attributes on <ncc> must stay available to the client runtime.

Out of scope

The client reveal (#718), the ISR cache (#717) and the boot gate have their own issues.

Checks

Selectors written against the wrapper-free markup give the same computed style in server mode and
in client mode. The layout and island unit tests still pass.

Dominant language
Python
Stars
11
Forks
6
Avg merge
2h 14m
Merged PRs (30d)
265

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NexyPy/nexy

All issues in NexyPy/nexy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.