ProjectEvergreen / ProjectEvergreen/wcc

Fragment (empty) tag support

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

Nobody has claimed this yet.

feature JSX
Dominant language
JavaScript
Stars
126
Forks
17
PR merge metrics
No merged PRs in 30d

Description

Summary

One rule with JSX is that there can only be one top level node in the render tree.

export default class Header extends HTMLElement {

  connectedCallback() {
    this.render();
  }

  render() {
    return (
      <header>
        <nav>...</nav>
      </header>
      <h1>Welcome to my website!</h1>
    );
  }
}

customElements.define('app-header', Header);

Screenshot 2024-01-06 at 12 57 48 PM

Details

The "fragment" wrapping tag convention can effectively act as a pass through tag that wont be part of the rendered output, but helps from a quality of life perspective when authoring JSX

export default class Header extends HTMLElement {

  connectedCallback() {
    this.render();
  }

  render() {
    return (
      <>
        <header>
          <nav>...</nav>
        </header>
        <h1>Welcome to my website!</h1>
      </>
    );
  }
}

customElements.define('app-header', Header);

Contributor guide

Open the contributing guide

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.

Research direction

Start by locating the JSX parsing and rendering entry points responsible for enforcing a single top-level node. Trace how JSX fragments are represented and emitted, then verify that the fragment wrapper is omitted while its children remain in the rendered output. Add or update coverage for the empty fragment syntax shown in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.