npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@supersede/jsx-dom

v6.4.2

Published

JSX to document.createElement.

Downloads

16

Readme

jsx-dom

License build status dependency status devDependency status npm version big mood

Use JSX for creating DOM elements.

Installation

npm install --save jsx-dom
yarn install jsx-dom

Usage

Note: If you previously use h as pragma, there is nothing you need to change.

import * as React from 'jsx-dom';

// DOM Elements.
document.body.appendChild(
  <div id="greeting" class="alert">Hello World</div>
);

// Functional components
// `defaultProps` and `props.children` are supported natively and work as you expected.
function Hello(props) {
  return <div>Hello {props.firstName}, {props.lastName}!</div>;
}

document.body.appendChild(
  <Hello firstName="Johny" lastName="Appleseed" />
);

Syntax

jsx-dom is based on the React JSX syntax with a few additions:

Class

  1. class is supported as an attribute as well as className.

  2. class can take:

    • a string
    • an object with the format { [key: string]: boolean }. Keys with a truthy value will be added to the classList
    • an array of values where falsy values (see below) are filtered out
    • an array of any combination of the above

Note that false, true, null, undefined will be ignored per React documentations, and everything else will be used. For example,

<div class="greeting" />
<div class={[ condition && "class" ]} />
<div class={{ hidden: isHidden, 'has-item': this.array.length > 0 }} />
<div class={[ classArray1, classArray2, ['nested'] ]} />

Style

  1. style accepts both strings and objects.
<div style="background: transparent;" />
<div style={{ background: 'transparent', fontFamily: 'serif' }} />

Other Attributes

  1. dataset accepts an object, where keys with a null or undefined value will be ignored.
<div dataset={{ user: "guest", isLoggedIn: false }} />
  1. Attributes starts with on and has a function value will be treated as an event listener and attached to the node with addEventListener.
<div onClick={ e => e.preventDefault() } />
  1. innerHTML, innerText and textContent are accepted.

  2. ref accepts either 1) a callback (node: Element) => void that allows access to the node after being created, or 2) a React style ref object. This is useful when you have a nested node tree and need to access a node inside without creating an intermediary variable.

// Callback
<input ref={ node => $(node).typehead({ hint: true }) } />

// React.createRef
import * as React from 'jsx-dom';

const textbox = React.createRef();
render(
  <div>
    <label>Username:</label>
    <input ref={ textbox } />
  </div>
);

window.onerror = () => {
  textbox.current.focus();
};

Functional components

You can write functional components and receive passed props in the same way in React. Unlike React, props.children is guaranteed to be an array.

SVG and Namespaces

A custom build with a list of commonly used SVG tags is included.

// Use 'jsx-dom/svg';
import * as React from 'jsx-dom/svg';

document.body.appendChild(
  <div class="flag" style={{ display: 'flex' }}>
    <h1>Flag of Italy</h1>
    <svg width="150" height="100" viewBox="0 0 3 2" class="flag italy">
      <rect width="1" height="2" x="0" fill="#008d46" />
      <rect width="1" height="2" x="1" fill="#ffffff" />
      <rect width="1" height="2" x="2" fill="#d2232c" />
    </svg>
  </div>
);

Below is a list of SVG tags included.

svg, animate, circle, clipPath, defs, desc, ellipse, feBlend, feColorMatrix, feComponentTransfer, feComposite, feConvolveMatrix, feDiffuseLighting, feDisplacementMap, feDistantLight, feFlood, feFuncA, feFuncB, feFuncG, feFuncR, feGaussianBlur, feImage, feMerge, feMergeNode, feMorphology, feOffset, fePointLight, feSpecularLighting, feSpotLight, feTile, feTurbulence, filter, foreignObject, g, image, line, linearGradient, marker, mask, metadata, path, pattern, polygon, polyline, radialGradient, rect, stop, switch, symbol, text, textPath, tspan, use, view

If you need to create an SVG element that is not in the list, or you want to specify a custom namespace, use the attribute namespaceURI.

import * as React from 'jsx-dom';

<a namespaceURI={ React.SVGNamespace }>I am an SVG element!</a>

Goodies

Two extra functions and one constant are provided by this package:

  1. preventDefault(event: Event): Event
  2. stopPropagation(event: Event): Event
  3. SVGNamespace is the namespaceURI string for SVG Elements.

Browser Support

jsx-dom requires Object.keys and Object.create support. This means IE9 or later.

Known Issues

<div />, and other tags, are inferred as a general JSX.Element in TypeScript instead of HTMLDivElement (or the equivalents). This is a known bug and its fix depends on TypeScript#21699.