preact-jsx-runtime
Advanced tools
Comparing version
@@ -0,1 +1,7 @@ | ||
## 1.1.0 (2020-08-16) | ||
### Performance | ||
- Optimize to avoid iterating properties in simple props pass-through case. | ||
## 1.0.1 (2020-08-09) | ||
@@ -2,0 +8,0 @@ |
var preact = require('preact'); | ||
/** @typedef {import('preact').ComponentType} ComponentType */ | ||
/** @typedef {import('preact/src/jsx').JSXInternal.HTMLAttributes} HTMLAttributes */ | ||
/** @typedef {import('preact/src/jsx').JSXInternal.SVGAttributes} SVGAttributes */ | ||
/** @typedef {HTMLAttributes & SVGAttributes & Record<string, any>} Props | ||
/** | ||
* @param {import('preact').ComponentType} type Component type. | ||
* @param {import('preact').Attributes} config Component props. | ||
* @param {string=} maybeKey Key, or undefined. | ||
* @param {ComponentType} type Component type. | ||
* @param {Props} config Component props. | ||
* @param {string=} maybeKey Key, or undefined. | ||
*/ | ||
function jsx(type, config, maybeKey) { | ||
var props = {}, | ||
propName; | ||
/** @type {Props} */ | ||
var props; | ||
if (maybeKey !== undefined) { | ||
props.key = '' + maybeKey; | ||
} | ||
/** @type {string} */ | ||
var propName; | ||
for (propName in config) { | ||
if (Object.prototype.hasOwnProperty.call(config, propName)) { | ||
props[propName] = config[propName]; | ||
if (maybeKey === undefined) { | ||
props = config; | ||
} else { | ||
props = { | ||
key: '' + maybeKey, | ||
}; | ||
for (propName in config) { | ||
if (Object.prototype.hasOwnProperty.call(config, propName)) { | ||
props[propName] = config[propName]; | ||
} | ||
} | ||
@@ -20,0 +32,0 @@ } |
{ | ||
"name": "preact-jsx-runtime", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Preact JSX runtime definition for use with automatic JSX import", | ||
@@ -5,0 +5,0 @@ "main": "jsx-runtime.js", |
5817
8.87%34
41.67%