jsx-dom-runtime
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -29,13 +29,7 @@ 'use strict'; | ||
var parseFromString = function parseFromString(html) { | ||
var node = document.createElement('p'); | ||
var node = document.createElement( | ||
/* just the shorter tag name than the `div` */ | ||
'p'); | ||
node.innerHTML = html; | ||
var childNodes = node.childNodes; | ||
var i = childNodes.length; | ||
var list = Array(i); | ||
while (0 < i--) { | ||
list[i] = childNodes[i]; | ||
} | ||
return list; | ||
return [].slice.call(node.childNodes); | ||
}; | ||
@@ -42,0 +36,0 @@ |
@@ -21,13 +21,7 @@ let createRef = () => ({ | ||
let parseFromString = html => { | ||
let node = document.createElement('p'); | ||
let node = document.createElement( | ||
/* just the shorter tag name than the `div` */ | ||
'p'); | ||
node.innerHTML = html; | ||
let childNodes = node.childNodes; | ||
let i = childNodes.length; | ||
let list = Array(i); | ||
while (0 < i--) { | ||
list[i] = childNodes[i]; | ||
} | ||
return list; | ||
return [].slice.call(node.childNodes); | ||
}; | ||
@@ -34,0 +28,0 @@ |
@@ -23,13 +23,7 @@ var createRef = function createRef() { | ||
var parseFromString = function parseFromString(html) { | ||
var node = document.createElement('p'); | ||
var node = document.createElement( | ||
/* just the shorter tag name than the `div` */ | ||
'p'); | ||
node.innerHTML = html; | ||
var childNodes = node.childNodes; | ||
var i = childNodes.length; | ||
var list = Array(i); | ||
while (0 < i--) { | ||
list[i] = childNodes[i]; | ||
} | ||
return list; | ||
return [].slice.call(node.childNodes); | ||
}; | ||
@@ -36,0 +30,0 @@ |
@@ -9,10 +9,8 @@ 'use strict'; | ||
let appendChildren = (node, children) => { | ||
if (children != null && children !== false) { | ||
if (isArray(children)) { | ||
for (let i = 0; children.length > i;) { | ||
appendChildren(node, children[i++]); | ||
} | ||
} else { | ||
node.appendChild(children.nodeType > 0 ? children : doc.createTextNode(children)); | ||
if (isArray(children)) { | ||
for (let i = 0; children.length > i;) { | ||
appendChildren(node, children[i++]); | ||
} | ||
} else if (children != null && children !== false) { | ||
node.appendChild(children.nodeType > 0 ? children : doc.createTextNode(children)); | ||
} | ||
@@ -27,4 +25,4 @@ }; | ||
let ref = props.ref; | ||
let node = typeof el === 'string' ? doc.createElement(el) : el; | ||
let ref = props.ref; | ||
@@ -43,4 +41,9 @@ for (let key in props) { | ||
} else { | ||
for (let s in val) { | ||
node.style[s] = val[s]; | ||
// reuse `key` variable | ||
for (key in val) { | ||
if (key[0] === '-') { | ||
node.style.setProperty(key, val[key]); | ||
} else { | ||
node.style[key] = val[key]; | ||
} | ||
} | ||
@@ -56,3 +59,3 @@ } // Benchmark for comparison (thanks preact): https://esbench.com/bench/574c954bdb965b9a00965ac6 | ||
} else if (val != null) { | ||
if (typeof val !== 'boolean' || /^(aria|data)-/.test(key)) { | ||
if (typeof val !== 'boolean' || /^(ari|dat)a-/.test(key)) { | ||
node.setAttribute(key, val); | ||
@@ -59,0 +62,0 @@ } else if (val) { |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:!0});var e=Array.isArray,t=document,r=function r(n,o){if(null!=o&&!1!==o)if(e(o))for(var i=0;o.length>i;)r(n,o[i++]);else n.appendChild(o.nodeType>0?o:t.createTextNode(o))},n=new Set(["innerHTML","textContent","value","htmlFor"]),o=function(o,i){if("function"==typeof o)return o(i);var s="string"==typeof o?t.createElement(o):o,l=i.ref;for(var a in i)if("ref"!==a&&"children"!==a){var f=i[a];if("className"===a)s.setAttribute("class",e(f)?f.filter(Boolean).join(" "):f);else if(n.has(a))s[a]=f;else if("style"===a)if("string"==typeof f)s.style.cssText=f;else for(var u in f)s.style[u]=f[u];else"o"===a[0]&&"n"===a[1]?(a=a.toLowerCase())in s&&(s[a]=f):null!=f?"boolean"!=typeof f||/^(aria|data)-/.test(a)?s.setAttribute(a,f):f?s.setAttribute(a,""):s.removeAttribute(a):s.removeAttribute(a)}return r(s,i.children),null!=l&&("function"==typeof l?l(s):l.current=s),s};exports.Fragment=function(e){var n=t.createDocumentFragment();return r(n,e.children),n},exports.jsx=o,exports.jsxs=o; | ||
Object.defineProperty(exports,"__esModule",{value:!0});var e=Array.isArray,t=document,r=function r(n,o){if(e(o))for(var s=0;o.length>s;)r(n,o[s++]);else null!=o&&!1!==o&&n.appendChild(o.nodeType>0?o:t.createTextNode(o))},n=new Set(["innerHTML","textContent","value","htmlFor"]),o=function(o,s){if("function"==typeof o)return o(s);var i=s.ref,l="string"==typeof o?t.createElement(o):o;for(var a in s)if("ref"!==a&&"children"!==a){var f=s[a];if("className"===a)l.setAttribute("class",e(f)?f.filter(Boolean).join(" "):f);else if(n.has(a))l[a]=f;else if("style"===a)if("string"==typeof f)l.style.cssText=f;else for(a in f)"-"===a[0]?l.style.setProperty(a,f[a]):l.style[a]=f[a];else"o"===a[0]&&"n"===a[1]?(a=a.toLowerCase())in l&&(l[a]=f):null!=f?"boolean"!=typeof f||/^(ari|dat)a-/.test(a)?l.setAttribute(a,f):f?l.setAttribute(a,""):l.removeAttribute(a):l.removeAttribute(a)}return r(l,s.children),null!=i&&("function"==typeof i?i(l):i.current=l),l};exports.Fragment=function(e){var n=t.createDocumentFragment();return r(n,e.children),n},exports.jsx=o,exports.jsxs=o; |
@@ -1,1 +0,1 @@ | ||
let e=Array.isArray,t=document,r=(n,l)=>{if(null!=l&&!1!==l)if(e(l))for(let e=0;l.length>e;)r(n,l[e++]);else n.appendChild(l.nodeType>0?l:t.createTextNode(l))},n=e=>{let n=t.createDocumentFragment();return r(n,e.children),n},l=new Set(["innerHTML","textContent","value","htmlFor"]),i=(n,i)=>{if("function"==typeof n)return n(i);let o="string"==typeof n?t.createElement(n):n,s=i.ref;for(let t in i)if("ref"!==t&&"children"!==t){let r=i[t];if("className"===t)o.setAttribute("class",e(r)?r.filter(Boolean).join(" "):r);else if(l.has(t))o[t]=r;else if("style"===t)if("string"==typeof r)o.style.cssText=r;else for(let e in r)o.style[e]=r[e];else"o"===t[0]&&"n"===t[1]?(t=t.toLowerCase(),t in o&&(o[t]=r)):null!=r?"boolean"!=typeof r||/^(aria|data)-/.test(t)?o.setAttribute(t,r):r?o.setAttribute(t,""):o.removeAttribute(t):o.removeAttribute(t)}return r(o,i.children),null!=s&&("function"==typeof s?s(o):s.current=o),o};export{n as Fragment,i as jsx,i as jsxs}; | ||
let e=Array.isArray,t=document,r=(n,l)=>{if(e(l))for(let e=0;l.length>e;)r(n,l[e++]);else null!=l&&!1!==l&&n.appendChild(l.nodeType>0?l:t.createTextNode(l))},n=e=>{let n=t.createDocumentFragment();return r(n,e.children),n},l=new Set(["innerHTML","textContent","value","htmlFor"]),i=(n,i)=>{if("function"==typeof n)return n(i);let o=i.ref,s="string"==typeof n?t.createElement(n):n;for(let t in i)if("ref"!==t&&"children"!==t){let r=i[t];if("className"===t)s.setAttribute("class",e(r)?r.filter(Boolean).join(" "):r);else if(l.has(t))s[t]=r;else if("style"===t)if("string"==typeof r)s.style.cssText=r;else for(t in r)"-"===t[0]?s.style.setProperty(t,r[t]):s.style[t]=r[t];else"o"===t[0]&&"n"===t[1]?(t=t.toLowerCase(),t in s&&(s[t]=r)):null!=r?"boolean"!=typeof r||/^(ari|dat)a-/.test(t)?s.setAttribute(t,r):r?s.setAttribute(t,""):s.removeAttribute(t):s.removeAttribute(t)}return r(s,i.children),null!=o&&("function"==typeof o?o(s):o.current=s),s};export{n as Fragment,i as jsx,i as jsxs}; |
@@ -5,14 +5,12 @@ let isArray = Array.isArray; | ||
let appendChildren = (node, children) => { | ||
if (children != null && children !== false) { | ||
if (isArray(children)) { | ||
for (let i = 0; children.length > i;) { | ||
appendChildren(node, children[i++]); | ||
} | ||
} else { | ||
node.appendChild( | ||
children.nodeType > 0 | ||
? children | ||
: doc.createTextNode(children) | ||
); | ||
if (isArray(children)) { | ||
for (let i = 0; children.length > i;) { | ||
appendChildren(node, children[i++]); | ||
} | ||
} else if (children != null && children !== false) { | ||
node.appendChild( | ||
children.nodeType > 0 | ||
? children | ||
: doc.createTextNode(children) | ||
); | ||
} | ||
@@ -40,4 +38,4 @@ }; | ||
let ref = props.ref; | ||
let node = typeof el === 'string' ? doc.createElement(el) : el; | ||
let ref = props.ref; | ||
@@ -61,4 +59,9 @@ for (let key in props) { | ||
} else { | ||
for (let s in val) { | ||
node.style[s] = val[s]; | ||
// reuse `key` variable | ||
for (key in val) { | ||
if (key[0] === '-') { | ||
node.style.setProperty(key, val[key]); | ||
} else { | ||
node.style[key] = val[key]; | ||
} | ||
} | ||
@@ -74,3 +77,3 @@ } | ||
} else if (val != null) { | ||
if (typeof val !== 'boolean' || /^(aria|data)-/.test(key)) { | ||
if (typeof val !== 'boolean' || /^(ari|dat)a-/.test(key)) { | ||
node.setAttribute(key, val); | ||
@@ -77,0 +80,0 @@ } else if (val) { |
@@ -1,1 +0,1 @@ | ||
var e=Array.isArray,t=document,r=function r(n,i){if(null!=i&&!1!==i)if(e(i))for(var o=0;i.length>o;)r(n,i[o++]);else n.appendChild(i.nodeType>0?i:t.createTextNode(i))},n=function(e){var n=t.createDocumentFragment();return r(n,e.children),n},i=new Set(["innerHTML","textContent","value","htmlFor"]),o=function(n,o){if("function"==typeof n)return n(o);var a="string"==typeof n?t.createElement(n):n,l=o.ref;for(var s in o)if("ref"!==s&&"children"!==s){var f=o[s];if("className"===s)a.setAttribute("class",e(f)?f.filter(Boolean).join(" "):f);else if(i.has(s))a[s]=f;else if("style"===s)if("string"==typeof f)a.style.cssText=f;else for(var u in f)a.style[u]=f[u];else"o"===s[0]&&"n"===s[1]?(s=s.toLowerCase())in a&&(a[s]=f):null!=f?"boolean"!=typeof f||/^(aria|data)-/.test(s)?a.setAttribute(s,f):f?a.setAttribute(s,""):a.removeAttribute(s):a.removeAttribute(s)}return r(a,o.children),null!=l&&("function"==typeof l?l(a):l.current=a),a};export{n as Fragment,o as jsx,o as jsxs}; | ||
var e=Array.isArray,t=document,r=function r(n,i){if(e(i))for(var o=0;i.length>o;)r(n,i[o++]);else null!=i&&!1!==i&&n.appendChild(i.nodeType>0?i:t.createTextNode(i))},n=function(e){var n=t.createDocumentFragment();return r(n,e.children),n},i=new Set(["innerHTML","textContent","value","htmlFor"]),o=function(n,o){if("function"==typeof n)return n(o);var l=o.ref,s="string"==typeof n?t.createElement(n):n;for(var a in o)if("ref"!==a&&"children"!==a){var f=o[a];if("className"===a)s.setAttribute("class",e(f)?f.filter(Boolean).join(" "):f);else if(i.has(a))s[a]=f;else if("style"===a)if("string"==typeof f)s.style.cssText=f;else for(a in f)"-"===a[0]?s.style.setProperty(a,f[a]):s.style[a]=f[a];else"o"===a[0]&&"n"===a[1]?(a=a.toLowerCase())in s&&(s[a]=f):null!=f?"boolean"!=typeof f||/^(ari|dat)a-/.test(a)?s.setAttribute(a,f):f?s.setAttribute(a,""):s.removeAttribute(a):s.removeAttribute(a)}return r(s,o.children),null!=l&&("function"==typeof l?l(s):l.current=s),s};export{n as Fragment,o as jsx,o as jsxs}; |
{ | ||
"name": "jsx-dom-runtime", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "A tiny in 500 bytes library to JSX syntax templates for DOM", | ||
@@ -63,11 +63,11 @@ "main": "dist/index.cjs.js", | ||
"path": "jsx-runtime/jsxRuntime.esm.js", | ||
"limit": "472 B" | ||
"limit": "482 B" | ||
}, | ||
{ | ||
"path": "jsx-runtime/jsxRuntime.cjs.js", | ||
"limit": "462 B" | ||
"limit": "474 B" | ||
}, | ||
{ | ||
"path": "jsx-runtime/jsxRuntime.module.js", | ||
"limit": "470 B" | ||
"limit": "482 B" | ||
} | ||
@@ -74,0 +74,0 @@ ], |
@@ -37,3 +37,3 @@ # jsx-dom-runtime | ||
const addItem = () => { | ||
// append to the end the of list | ||
// append to the end of the list | ||
<List.current> | ||
@@ -54,3 +54,3 @@ <li>New Item</li> | ||
// append to the end the of head | ||
// append to the end of the head | ||
<document.head> | ||
@@ -60,3 +60,3 @@ <link rel="stylesheet" href="/style.css" /> | ||
// append to the end the of body | ||
// append to the end the the body | ||
<document.body id="root"> | ||
@@ -63,0 +63,0 @@ <App /> |
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
26061
556