
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Use JSX for creating DOM elements.
npm install --save jsx-dom
import { createElement } from 'jsx-dom';
document.body.appendChild( <div id="greeting" class="alert">Hello World</div> );
You need to tell your transpiler to use the name createElement
. If you prefer not to, skip to the next section for instrutions. For Babel users, specify within your .babelrc
:
{
"plugins": [
[ "transform-react-jsx", { "pragma": "createElement" } ]
]
}
Or if you prefer to work with TypeScript:
// In tsconfig.json:
{
"jsx": "react",
"jsxFactory": "createElement",
}
.babelrc
or tsconfig
optionsIf you don’t want to configure your transpiler to use jsx-dom
, simply import it using
the React namespace:
import * as React from 'jsx-dom';
jsx-dom
is based on the React JSX syntax with a few additions:
class
is supported as an attribute as well as className
class
can take an object with the format { [key: string]: boolean }
. Keys with a truthy value will be added to the classList.class
can also take an array of values:
Note that false
, true
, null
, undefined
will be ignored per React documentations, and everything else will be used. As an example: <div class={[ condition && "class" ]} />
;style
accepts both strings and objects.dataset
accepts an object.on
and has a function value will be treated as an event listener and thus attached to the node.innerHTML
, innerText
and textContent
are accepted.Two extra functions are provided by this package:
preventDefault(event: Event): Event
stopPropagation(event: Event): Event
jsx-dom
requires Object.keys
support. This means IE9 or later.
FAQs
JSX to document.createElement.
The npm package jsx-dom receives a total of 7,290 weekly downloads. As such, jsx-dom popularity was classified as popular.
We found that jsx-dom demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.