jsx-dom-runtime
Advanced tools
Comparing version 0.58.2 to 0.59.0
@@ -16,3 +16,15 @@ const appendChildren = (children, node) => { | ||
const internalKeys = new Set(['ns', 'children', 'ref']); | ||
const extensions = new Map(); | ||
const extensions = new Map([['style', (node, val, key) => { | ||
if (typeof val === 'string') { | ||
node.setAttribute(key, val); | ||
} else { | ||
for (key in val) { | ||
if (key.startsWith('--')) { | ||
node.style.setProperty(key, val[key]); | ||
} else { | ||
node.style[key] = val[key]; | ||
} | ||
} | ||
} | ||
}]]); | ||
const properties = new Set(['value']); | ||
@@ -24,34 +36,21 @@ const jsx = (tag, props) => { | ||
for (key in props) { | ||
if (internalKeys.has(key)) { | ||
continue; | ||
} | ||
val = props[key]; | ||
if (extensions.has(key)) { | ||
extensions.get(key)(node, val, key); | ||
} else if (key === 'style') { | ||
if (typeof val === 'string') { | ||
node.style.cssText = val; | ||
} else { | ||
for (key in val) { | ||
if (key.startsWith('--')) { | ||
node.style.setProperty(key, val[key]); | ||
} else { | ||
node.style[key] = val[key]; | ||
} | ||
} | ||
if (!internalKeys.has(key)) { | ||
val = props[key]; | ||
if (extensions.has(key)) { | ||
extensions.get(key)(node, val, key); | ||
} else if (properties.has(key) || key.startsWith('on')) { | ||
node[key] = val; | ||
} else if (val != null && (typeof val !== 'boolean' || key[4] === '-')) { | ||
node.setAttribute(key, val); | ||
} else if (val) { | ||
node.setAttribute(key, ''); | ||
} | ||
} else if (properties.has(key) || key.startsWith('on') && key in node) { | ||
node[key] = val; | ||
} else if (val != null && (typeof val !== 'boolean' || key[4] === '-')) { | ||
node.setAttribute(key, val); | ||
} else if (val) { | ||
node.setAttribute(key, ''); | ||
} | ||
} | ||
appendChildren(props.children, tag === 'template' ? node.content : node); | ||
if (val = props.ref) { | ||
if (typeof val === 'function') { | ||
val(node); | ||
if (key = props.ref) { | ||
if (typeof key === 'function') { | ||
key(node); | ||
} else { | ||
val.current = node; | ||
key.current = node; | ||
} | ||
@@ -86,6 +85,6 @@ } | ||
const xhtmlNS = 'http://www.w3.org/1999/xhtml'; | ||
const svgNS = 'http://www.w3.org/2000/svg'; | ||
const mathmlNS = 'http://www.w3.org/1998/Math/MathML'; | ||
const xhtmlNs = 'http://www.w3.org/1999/xhtml'; | ||
const svgNs = 'http://www.w3.org/2000/svg'; | ||
const mathmlNs = 'http://www.w3.org/1998/Math/MathML'; | ||
export { Fragment, Template, appendChildren, extensions, jsx, mathmlNS, parseFromString, properties, svgNS, useRef, useText, xhtmlNS }; | ||
export { Fragment, Template, appendChildren, extensions, jsx, mathmlNs, parseFromString, properties, svgNs, useRef, useText, xhtmlNs }; |
{ | ||
"name": "jsx-dom-runtime", | ||
"version": "0.58.2", | ||
"version": "0.59.0", | ||
"description": "A tiny in 500 bytes library to JSX syntax templates for DOM. Support HTML, SVG and MathML tags", | ||
@@ -35,4 +35,4 @@ "type": "module", | ||
"@babel/plugin-syntax-jsx": "^7.23.3", | ||
"@babel/types": "^7.23.3", | ||
"csstype": "^3.1.2", | ||
"@babel/types": "^7.23.5", | ||
"csstype": "^3.1.3", | ||
"html-tags": "^3.3.1", | ||
@@ -45,23 +45,23 @@ "svg-tags": "^1.0.0" | ||
"devDependencies": { | ||
"@babel/core": "^7.23.3", | ||
"@babel/core": "^7.23.5", | ||
"@babel/preset-typescript": "^7.23.3", | ||
"@evilmartians/lefthook": "^1.5.2", | ||
"@evilmartians/lefthook": "^1.5.5", | ||
"@jest/globals": "^29.7.0", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@size-limit/preset-small-lib": "^11.0.0", | ||
"@size-limit/preset-small-lib": "^11.0.1", | ||
"@testing-library/dom": "^9.3.3", | ||
"@testing-library/jest-dom": "^6.1.4", | ||
"@testing-library/jest-dom": "^6.1.5", | ||
"@types/babel__helper-validator-identifier": "^7.15.2", | ||
"@types/jest": "^29.5.8", | ||
"@types/jest": "^29.5.11", | ||
"@types/svg-tags": "^1.0.2", | ||
"@typescript-eslint/eslint-plugin": "^6.11.0", | ||
"@typescript-eslint/parser": "^6.11.0", | ||
"@typescript-eslint/eslint-plugin": "^6.13.2", | ||
"@typescript-eslint/parser": "^6.13.2", | ||
"babel-jest": "^29.7.0", | ||
"eslint": "^8.54.0", | ||
"eslint": "^8.55.0", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"rollup": "^4.5.0", | ||
"size-limit": "^11.0.0", | ||
"typescript": "^5.2.2" | ||
"rollup": "^4.7.0", | ||
"size-limit": "^11.0.1", | ||
"typescript": "^5.3.3" | ||
}, | ||
@@ -68,0 +68,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103715
2694
Updated@babel/types@^7.23.5
Updatedcsstype@^3.1.3