jsx-dom-runtime
Advanced tools
Comparing version 0.8.0 to 0.9.0
@@ -52,4 +52,6 @@ 'use strict'; | ||
} | ||
} else if (typeof val === 'boolean' && !/^(aria|data)-/.test(key)) { | ||
if (val) { | ||
} else if (val != null) { | ||
if (typeof val !== 'boolean' || /^(aria|data)-/.test(key)) { | ||
node.setAttribute(key, val); | ||
} else if (val) { | ||
node.setAttribute(key, ''); | ||
@@ -59,4 +61,4 @@ } else { | ||
} | ||
} else if (val != null) { | ||
node.setAttribute(key, val); | ||
} else { | ||
node.removeAttribute(key); | ||
} | ||
@@ -165,3 +167,4 @@ } | ||
return new PropTypeError(`Invalid prop \`${key}\` of type "${value}", expected one of "${list.join('", "')}"`, list); | ||
const preciseType = String(value).slice(0, 100); | ||
return new PropTypeError(`Invalid prop \`${key}\` of type "${preciseType}", expected one of "${list.join('", "')}"`, list); | ||
}); | ||
@@ -276,2 +279,3 @@ }; | ||
const referrerPolicy = T.oneOf(['', 'no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', 'same-origin', 'strict-origin', 'strict-origin-when-cross-origin', 'unsafe-url']); | ||
const a = { | ||
@@ -282,3 +286,5 @@ href: T.string.isRequired, | ||
type: T.string, | ||
target: T.oneOf(['_blank', '_self', '_parent', '_top']) | ||
target: T.oneOf(['_blank', '_self', '_parent', '_top']), | ||
referrerPolicy, | ||
referrerpolicy: referrerPolicy | ||
}; | ||
@@ -323,2 +329,3 @@ | ||
readOnly: T.bool, | ||
readonly: T.bool, | ||
required: T.bool | ||
@@ -341,15 +348,26 @@ }; | ||
const printValue = val => { | ||
if (Array.isArray(val)) return '{ […] }'; | ||
if (typeof val === 'object') return '{ {…} }'; | ||
if (typeof val === 'string') return `"${val.slice(0, 100)}"`; | ||
if (typeof val === 'function') return '{ () => … }'; | ||
return `{ ${val} }`; | ||
}; | ||
const propTypes = (tagName, spec, props, stack) => { | ||
for (const key in props) { | ||
let error; | ||
if (key in spec) { | ||
const value = props[key]; | ||
let error; | ||
try { | ||
error = spec[key](key, props[key]); | ||
} catch (ex) { | ||
error = ex; | ||
} | ||
try { | ||
error = spec[key](key, value); | ||
} catch (ex) { | ||
error = ex; | ||
} | ||
if (error != null) { | ||
console.error(`${error?.message}\n\n`, `<${tagName}> at [${stack.lineNumber}:${stack.columnNumber}] - ${stack.fileName}`); | ||
break; | ||
if (error != null) { | ||
console.error(`<${tagName} ${key}=${printValue(value)}>\n\n`, `${error?.message}\n\n`, `at [${stack.lineNumber}:${stack.columnNumber}] - ${stack.fileName}`); | ||
break; | ||
} | ||
} | ||
@@ -356,0 +374,0 @@ } |
@@ -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):"boolean"!=typeof f||/^(aria|data)-/.test(a)?null!=f&&s.setAttribute(a,f):f?s.setAttribute(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(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; |
@@ -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)):"boolean"!=typeof r||/^(aria|data)-/.test(t)?null!=r&&o.setAttribute(t,r):r?o.setAttribute(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(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}; |
@@ -70,4 +70,6 @@ let isArray = Array.isArray; | ||
} | ||
} else if (typeof val === 'boolean' && !/^(aria|data)-/.test(key)) { | ||
if (val) { | ||
} else if (val != null) { | ||
if (typeof val !== 'boolean' || /^(aria|data)-/.test(key)) { | ||
node.setAttribute(key, val); | ||
} else if (val) { | ||
node.setAttribute(key, ''); | ||
@@ -77,4 +79,4 @@ } else { | ||
} | ||
} else if (val != null) { | ||
node.setAttribute(key, val); | ||
} else { | ||
node.removeAttribute(key); | ||
} | ||
@@ -81,0 +83,0 @@ } |
@@ -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):"boolean"!=typeof f||/^(aria|data)-/.test(s)?null!=f&&a.setAttribute(s,f):f?a.setAttribute(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(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}; |
{ | ||
"name": "jsx-dom-runtime", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "A tiny in 500 bytes library to JSX syntax templates for DOM", | ||
@@ -63,3 +63,3 @@ "main": "dist/index.cjs.js", | ||
"path": "jsx-runtime/jsxRuntime.esm.js", | ||
"limit": "469 B" | ||
"limit": "472 B" | ||
}, | ||
@@ -66,0 +66,0 @@ { |
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
25892
561