Skip to content

Bug: Unsupported HTML character references #28820

@valtlai

Description

@valtlai

React does not support all the named character references, “entities”, defined in the HTML specification:

React version: 18.2.0

Steps To Reproduce

Render the following demo component and compare the exepcteds character and the actual rendering results.

Code demo
const HTMLCharRefDemo = () => (
  <>
    <h1>Test: HTML character references in React</h1>
    <table>
      <thead>
        <tr>
          <th>Reference</th>
          <th>Expected character</th>
          <th>Actual rendering</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>&amp;copy;</td>
          <td>©</td>
          <td>&copy;</td>
        </tr>
        <tr>
          <td>&amp;bemptyv;</td>
          <td></td>
          <td>&bemptyv;</td>
        </tr>
        <tr>
          <td>&amp;check;</td>
          <td></td>
          <td>&check;</td>
        </tr>
        <tr>
          <td>&amp;bigstar;</td>
          <td></td>
          <td>&bigstar;</td>
        </tr>
        <tr>
          <td>&amp;NoBreak;</td>
          <td>{'\u2060'}</td>
          <td>&NoBreak;</td>
        </tr>
      </tbody>
    </table>
  </>
);

Link to code example: https://codepen.io/valtlai/pen/qBwYezG?editors=1010

The current behavior

React does not recognize some character references but renders them as is.

The expected behavior

React should recognize all the specced character references that end with a semicolon and render the characters they represent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: StaleAutomatically closed due to inactivityStatus: UnconfirmedA potential issue that we haven't yet confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions