New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsx-dom

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsx-dom - npm Package Compare versions

Comparing version 8.1.2 to 8.1.3

3

CHANGELOG.md

@@ -0,1 +1,4 @@

# 8.1.3
- Merged #101.
# 8.1.1

@@ -2,0 +5,0 @@ - Undo: Removes all `*Capture` event listener types. They were never supported.

411

index.js
/* eslint-disable */
const keys = Object.keys
const keys = Object.keys;
function identity(value) {
return value
return value;
}
function isBoolean(val) {
return typeof val === "boolean"
return typeof val === "boolean";
}
function isElement(val) {
return val && typeof val.nodeType === "number"
return val && typeof val.nodeType === "number";
}
function isString(val) {
return typeof val === "string"
return typeof val === "string";
}
function isNumber(val) {
return typeof val === "number"
return typeof val === "number";
}
function isObject(val) {
return typeof val === "object" ? val !== null : isFunction(val)
return typeof val === "object" ? val !== null : isFunction(val);
}
function isFunction(val) {
return typeof val === "function"
return typeof val === "function";
}
function isComponentClass(Component) {
const { prototype } = Component
return !!(prototype && prototype.isReactComponent)
const { prototype } = Component;
return !!(prototype && prototype.isReactComponent);
}
function isArrayLike(obj) {
return isObject(obj) && typeof obj.length === "number" && typeof obj.nodeType !== "number"
return (
isObject(obj) &&
typeof obj.length === "number" &&
typeof obj.nodeType !== "number"
);
}
function forEach(value, fn) {
if (!value) return
if (!value) return;
for (const key of keys(value)) {
fn(value[key], key)
fn(value[key], key);
}

@@ -41,6 +45,6 @@ }

current: null,
})
});
}
function isRef(maybeRef) {
return isObject(maybeRef) && "current" in maybeRef
return isObject(maybeRef) && "current" in maybeRef;
}

@@ -102,3 +106,3 @@

strokeWidth: 0,
}
};

@@ -112,3 +116,3 @@ /**

function prefixKey(prefix, key) {
return prefix + key.charAt(0).toUpperCase() + key.substring(1)
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
}

@@ -120,18 +124,18 @@

*/
const prefixes = ["Webkit", "ms", "Moz", "O"]
const prefixes = ["Webkit", "ms", "Moz", "O"];
// Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
// infinite loop, because it iterates over the newly added props too.
keys(isUnitlessNumber).forEach(prop => {
prefixes.forEach(prefix => {
isUnitlessNumber[prefixKey(prefix, prop)] = 0 // isUnitlessNumber[prop]
})
})
keys(isUnitlessNumber).forEach((prop) => {
prefixes.forEach((prefix) => {
isUnitlessNumber[prefixKey(prefix, prop)] = 0; // isUnitlessNumber[prop]
});
});
const jsxDomType = Symbol.for("jsx-dom:type")
const jsxDomType = Symbol.for("jsx-dom:type");
var JsxDomType = /*#__PURE__*/ (function (JsxDomType) {
JsxDomType["ShadowRoot"] = "ShadowRoot"
return JsxDomType
})(JsxDomType || {})
JsxDomType["ShadowRoot"] = "ShadowRoot";
return JsxDomType;
})(JsxDomType || {});
function ShadowRoot(_ref) {
let { children, ref, ...attr } = _ref
let { children, ref, ...attr } = _ref;
return {

@@ -142,11 +146,11 @@ [jsxDomType]: JsxDomType.ShadowRoot,

children,
}
};
}
function isShadowRoot(el) {
return el != null && el[jsxDomType] === JsxDomType.ShadowRoot
return el != null && el[jsxDomType] === JsxDomType.ShadowRoot;
}
const SVGNamespace = "http://www.w3.org/2000/svg"
const XLinkNamespace = "http://www.w3.org/1999/xlink"
const XMLNamespace = "http://www.w3.org/XML/1998/namespace"
const SVGNamespace = "http://www.w3.org/2000/svg";
const XLinkNamespace = "http://www.w3.org/1999/xlink";
const XMLNamespace = "http://www.w3.org/XML/1998/namespace";

@@ -156,5 +160,4 @@ // https://facebook.github.io/react/docs/jsx-in-depth.html#booleans-null-and-undefined-are-ignored

function isVisibleChild(value) {
return !isBoolean(value) && value != null
return !isBoolean(value) && value != null;
}
const DomTokenList = typeof DOMTokenList !== "undefined" ? DOMTokenList : function () {}

@@ -167,13 +170,14 @@ /**

if (Array.isArray(value)) {
return value.map(className).filter(Boolean).join(" ")
} else if (value instanceof DomTokenList) {
return "" + value
return value.map(className).filter(Boolean).join(" ");
} else if (isObject(value)) {
if (Symbol.iterator in value) {
return className(Array.from(value));
}
return keys(value)
.filter(k => value[k])
.join(" ")
.filter((k) => value[k])
.join(" ");
} else if (isVisibleChild(value)) {
return "" + value
return "" + value;
} else {
return ""
return "";
}

@@ -236,19 +240,19 @@ }

view: 0,
}
};
const nonPresentationSVGAttributes =
/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/
/^(a(ll|t|u)|base[FP]|c(al|lipPathU|on)|di|ed|ex|filter[RU]|g(lyphR|r)|ke|l(en|im)|ma(rker[HUW]|s)|n|pat|pr|point[^e]|re[^n]|s[puy]|st[^or]|ta|textL|vi|xC|y|z)/;
function createFactory(tag) {
return createElement.bind(null, tag)
return createElement.bind(null, tag);
}
function Fragment(attr) {
const fragment = document.createDocumentFragment()
appendChild(attr.children, fragment)
return fragment
const fragment = document.createDocumentFragment();
appendChild(attr.children, fragment);
return fragment;
}
class Component {
constructor(props) {
this.props = props
this.props = props;
}
render() {
return null
return null;
}

@@ -262,3 +266,3 @@ }

},
})
});
function initComponentClass(Class, attr, children) {

@@ -268,5 +272,5 @@ attr = {

children,
}
const instance = new Class(attr)
return instance.render()
};
const instance = new Class(attr);
return instance.render();
}

@@ -276,3 +280,3 @@

function jsx(tag, _ref) {
let { children, ...attr } = _ref
let { children, ...attr } = _ref;
if (!attr.namespaceURI && svg[tag] === 0) {

@@ -282,11 +286,11 @@ attr = {

namespaceURI: SVGNamespace,
}
};
}
let node
let node;
if (isString(tag)) {
node = attr.namespaceURI
? document.createElementNS(attr.namespaceURI, tag)
: document.createElement(tag)
attributes(attr, node)
appendChild(children, node)
: document.createElement(tag);
attributes(attr, node);
appendChild(children, node);

@@ -296,11 +300,13 @@ // Select `option` elements in `select`

if (attr.multiple === true && Array.isArray(attr.value)) {
const values = attr.value.map(value => String(value))
const values = attr.value.map((value) => String(value));
node
.querySelectorAll("option")
.forEach(option => (option.selected = values.includes(option.value)))
.forEach(
(option) => (option.selected = values.includes(option.value)),
);
} else {
node.value = attr.value
node.value = attr.value;
}
}
attachRef(attr.ref, node)
attachRef(attr.ref, node);
} else if (isFunction(tag)) {

@@ -312,3 +318,3 @@ // Custom elements.

...attr,
}
};
}

@@ -320,23 +326,25 @@ node = isComponentClass(tag)

children,
})
});
} else {
throw new TypeError(`Invalid JSX element type: ${tag}`)
throw new TypeError(`Invalid JSX element type: ${tag}`);
}
return node
return node;
}
function createElement(tag, attr) {
for (
var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key2 = 2;
var _len = arguments.length,
children = new Array(_len > 2 ? _len - 2 : 0),
_key2 = 2;
_key2 < _len;
_key2++
) {
children[_key2 - 2] = arguments[_key2]
children[_key2 - 2] = arguments[_key2];
}
if (isString(attr) || Array.isArray(attr)) {
children.unshift(attr)
attr = {}
children.unshift(attr);
attr = {};
}
attr = attr || {}
attr = attr || {};
if (attr.children != null && !children.length) {
;({ children, ...attr } = attr)
({ children, ...attr } = attr);
}

@@ -349,10 +357,10 @@ return jsx(

},
attr.key
)
attr.key,
);
}
function attachRef(ref, node) {
if (isRef(ref)) {
ref.current = node
ref.current = node;
} else if (isFunction(ref)) {
ref(node)
ref(node);
}

@@ -362,13 +370,13 @@ }

if (isArrayLike(child)) {
appendChildren(child, node)
appendChildren(child, node);
} else if (isString(child) || isNumber(child)) {
appendChildToNode(document.createTextNode(child), node)
appendChildToNode(document.createTextNode(child), node);
} else if (child === null) {
appendChildToNode(document.createComment(""), node)
appendChildToNode(document.createComment(""), node);
} else if (isElement(child)) {
appendChildToNode(child, node)
appendChildToNode(child, node);
} else if (isShadowRoot(child)) {
const shadowRoot = node.attachShadow(child.attr)
appendChild(child.children, shadowRoot)
attachRef(child.ref, shadowRoot)
const shadowRoot = node.attachShadow(child.attr);
appendChild(child.children, shadowRoot);
attachRef(child.ref, shadowRoot);
}

@@ -378,15 +386,15 @@ }

for (const child of [...children]) {
appendChild(child, node)
appendChild(child, node);
}
return node
return node;
}
function appendChildToNode(child, node) {
if (node instanceof window.HTMLTemplateElement) {
node.content.appendChild(child)
node.content.appendChild(child);
} else {
node.appendChild(child)
node.appendChild(child);
}
}
function normalizeAttribute(s, separator) {
return s.replace(/[A-Z]/g, match => separator + match.toLowerCase())
return s.replace(/[A-Z]/g, (match) => separator + match.toLowerCase());
}

@@ -396,5 +404,5 @@ function style(node, value) {

else if (Array.isArray(value)) {
value.forEach(v => style(node, v))
value.forEach((v) => style(node, v));
} else if (isString(value)) {
node.setAttribute("style", value)
node.setAttribute("style", value);
} else if (isObject(value)) {

@@ -405,9 +413,9 @@ forEach(value, (val, key) => {

// and must be assigned via `setProperty`.
node.style.setProperty(key, val)
node.style.setProperty(key, val);
} else if (isNumber(val) && isUnitlessNumber[key] !== 0) {
node.style[key] = val + "px"
node.style[key] = val + "px";
} else {
node.style[key] = val
node.style[key] = val;
}
})
});
}

@@ -424,24 +432,24 @@ }

case "xlinkType":
attrNS(node, XLinkNamespace, normalizeAttribute(key, ":"), value)
return
attrNS(node, XLinkNamespace, normalizeAttribute(key, ":"), value);
return;
case "xmlnsXlink":
attr(node, normalizeAttribute(key, ":"), value)
return
attr(node, normalizeAttribute(key, ":"), value);
return;
case "xmlBase":
case "xmlLang":
case "xmlSpace":
attrNS(node, XMLNamespace, normalizeAttribute(key, ":"), value)
return
attrNS(node, XMLNamespace, normalizeAttribute(key, ":"), value);
return;
}
switch (key) {
case "htmlFor":
attr(node, "for", value)
return
attr(node, "for", value);
return;
case "dataset":
forEach(value, (dataValue, dataKey) => {
if (dataValue != null) {
node.dataset[dataKey] = dataValue
node.dataset[dataKey] = dataValue;
}
})
return
});
return;
case "innerHTML":

@@ -451,10 +459,10 @@ case "innerText":

if (isVisibleChild(value)) {
node[key] = value
node[key] = value;
}
return
return;
case "dangerouslySetInnerHTML":
if (isObject(value)) {
node.innerHTML = value["__html"]
node.innerHTML = value["__html"];
}
return
return;
case "value":

@@ -464,51 +472,54 @@ if (value == null || node instanceof window.HTMLSelectElement) {

// for `<select>` apply value after appending `<option>` elements
return
return;
} else if (node instanceof window.HTMLTextAreaElement) {
node.value = value
return
node.value = value;
return;
}
// use attribute for other elements
break
break;
case "spellCheck":
node.spellcheck = value
return
node.spellcheck = value;
return;
case "class":
case "className":
if (isFunction(value)) {
value(node)
value(node);
} else {
attr(node, "class", className(value))
attr(node, "class", className(value));
}
return
return;
case "ref":
case "namespaceURI":
return
return;
case "style":
style(node, value)
return
style(node, value);
return;
case "on":
case "onCapture":
forEach(value, (eventHandler, eventName) => {
node.addEventListener(eventName, eventHandler, key === "onCapture")
})
return
node.addEventListener(eventName, eventHandler, key === "onCapture");
});
return;
// fallthrough
}
if (isFunction(value)) {
if (key[0] === "o" && key[1] === "n") {
let attribute = key.toLowerCase()
const useCapture = attribute.endsWith("capture")
let attribute = key.toLowerCase();
const useCapture = attribute.endsWith("capture");
if (attribute === "ondoubleclick") {
attribute = "ondblclick"
attribute = "ondblclick";
} else if (useCapture && attribute === "ondoubleclickcapture") {
attribute = "ondblclickcapture"
attribute = "ondblclickcapture";
}
if (!useCapture && node[attribute] === null) {
// use property when possible PR #17
node[attribute] = value
node[attribute] = value;
} else if (useCapture) {
node.addEventListener(attribute.substring(2, attribute.length - 7), value, true)
node.addEventListener(
attribute.substring(2, attribute.length - 7),
value,
true,
);
} else {
let eventName
let eventName;
if (attribute in window) {

@@ -519,4 +530,4 @@ // standard event

// so let's add the listener "mouseover", which is all lowercased
const standardEventName = attribute.substring(2)
eventName = standardEventName
const standardEventName = attribute.substring(2);
eventName = standardEventName;
} else {

@@ -528,17 +539,17 @@ // custom event

// except for the first character, we keep the event name case
const customEventName = attribute[2] + key.slice(3)
eventName = customEventName
const customEventName = attribute[2] + key.slice(3);
eventName = customEventName;
}
node.addEventListener(eventName, value)
node.addEventListener(eventName, value);
}
}
} else if (isObject(value)) {
node[key] = value
node[key] = value;
} else if (value === true) {
attr(node, key, "")
attr(node, key, "");
} else if (value !== false && value != null) {
if (node instanceof SVGElement && !nonPresentationSVGAttributes.test(key)) {
attr(node, normalizeAttribute(key, "-"), value)
attr(node, normalizeAttribute(key, "-"), value);
} else {
attr(node, key, value)
attr(node, key, value);
}

@@ -548,38 +559,38 @@ }

function attr(node, key, value) {
node.setAttribute(key, value)
node.setAttribute(key, value);
}
function attrNS(node, namespace, key, value) {
node.setAttributeNS(namespace, key, value)
node.setAttributeNS(namespace, key, value);
}
function attributes(attr, node) {
for (const key of keys(attr)) {
attribute(key, attr[key], node)
attribute(key, attr[key], node);
}
return node
return node;
}
function useText(initialValue) {
const text = new Text()
const text = new Text();
Object.defineProperty(text, "toString", {
value() {
return this.textContent
return this.textContent;
},
})
});
function setText(value) {
text.textContent = value
text.textContent = value;
}
if (initialValue != null) {
setText(initialValue)
setText(initialValue);
}
return [text, setText]
return [text, setText];
}
function useClassList(initialValue) {
const div = document.createElement("div")
const div = document.createElement("div");
if (initialValue != null) {
div.className = className(initialValue)
div.className = className(initialValue);
}
let list = div.classList
let list = div.classList;
function ClassList(value) {
value.setAttribute("class", list.value)
list = value.classList
value.setAttribute("class", list.value);
list = value.classList;
}

@@ -590,72 +601,76 @@ Object.defineProperties(

get size() {
return list.length
return list.length;
},
get value() {
return list.value
return list.value;
},
add() {
list.add(...arguments)
list.add(...arguments);
},
remove() {
list.remove(...arguments)
list.remove(...arguments);
},
toggle(token, force) {
list.toggle(token, force)
list.toggle(token, force);
},
contains(token) {
return list.contains(token)
return list.contains(token);
},
})
)
return ClassList
}),
);
return ClassList;
}
function useMemo(factory) {
return factory()
return factory();
}
function forwardRef(render) {
return _ref => {
let { ref, ...props } = _ref
return render(props, ref ?? createRef())
}
return (_ref) => {
let { ref, ...props } = _ref;
return render(props, ref ?? createRef());
};
}
function useImperativeHandle(ref, init) {
attachRef(ref, init())
attachRef(ref, init());
}
const cache = /* @__PURE__ */ new Map()
const createStyledComponent = name =>
const cache = /* @__PURE__ */ new Map();
const createStyledComponent = (name) =>
function (list) {
for (
var _len = arguments.length, interpolations = new Array(_len > 1 ? _len - 1 : 0), _key = 1;
var _len = arguments.length,
interpolations = new Array(_len > 1 ? _len - 1 : 0),
_key = 1;
_key < _len;
_key++
) {
interpolations[_key - 1] = arguments[_key]
interpolations[_key - 1] = arguments[_key];
}
return _ref => {
let { style, ...props } = _ref
const lastIndex = list.length - 1
return (_ref) => {
let { style, ...props } = _ref;
const lastIndex = list.length - 1;
const css =
list.slice(0, lastIndex).reduce((p, s, i) => p + s + interpolations[i](props), "") +
list[lastIndex]
list
.slice(0, lastIndex)
.reduce((p, s, i) => p + s + interpolations[i](props), "") +
list[lastIndex];
return createElement(name, {
style: [css, style],
...props,
})
}
}
const baseStyled = customComponent => createStyledComponent(customComponent)
});
};
};
const baseStyled = (customComponent) => createStyledComponent(customComponent);
const styled = /* @__PURE__ */ new Proxy(baseStyled, {
get(_, name) {
return setIfAbsent(cache, name, () => createStyledComponent(name))
return setIfAbsent(cache, name, () => createStyledComponent(name));
},
})
});
function setIfAbsent(map, key, getValue) {
if (map.has(key)) {
return map.get(key)
return map.get(key);
} else {
const value = getValue(key)
map.set(key, value)
return value
const value = getValue(key);
map.set(key, value);
return value;
}

@@ -670,10 +685,10 @@ }

ShadowRoot,
}
};
function preventDefault(event) {
event.preventDefault()
return event
event.preventDefault();
return event;
}
function stopPropagation(event) {
event.stopPropagation()
return event
event.stopPropagation();
return event;
}

@@ -708,2 +723,2 @@

useText,
}
};
/* eslint-disable */
export { Fragment, jsx, jsx as jsxDEV, jsx as jsxs } from "jsx-dom"
export { Fragment, jsx, jsx as jsxDEV, jsx as jsxs } from "jsx-dom";
/* eslint-disable */
const keys = Object.keys
const keys = Object.keys;
function identity(value) {
return value
return value;
}
function isBoolean(val) {
return typeof val === "boolean"
return typeof val === "boolean";
}
function isElement(val) {
return val && typeof val.nodeType === "number"
return val && typeof val.nodeType === "number";
}
function isString(val) {
return typeof val === "string"
return typeof val === "string";
}
function isNumber(val) {
return typeof val === "number"
return typeof val === "number";
}
function isObject(val) {
return typeof val === "object" ? val !== null : isFunction(val)
return typeof val === "object" ? val !== null : isFunction(val);
}
function isFunction(val) {
return typeof val === "function"
return typeof val === "function";
}
function isComponentClass(Component) {
const { prototype } = Component
return !!(prototype && prototype.isReactComponent)
const { prototype } = Component;
return !!(prototype && prototype.isReactComponent);
}
function isArrayLike(obj) {
return isObject(obj) && typeof obj.length === "number" && typeof obj.nodeType !== "number"
return (
isObject(obj) &&
typeof obj.length === "number" &&
typeof obj.nodeType !== "number"
);
}
function forEach(value, fn) {
if (!value) return
if (!value) return;
for (const key of keys(value)) {
fn(value[key], key)
fn(value[key], key);
}

@@ -41,15 +45,15 @@ }

current: null,
})
});
}
function isRef(maybeRef) {
return isObject(maybeRef) && "current" in maybeRef
return isObject(maybeRef) && "current" in maybeRef;
}
const jsxDomType = Symbol.for("jsx-dom:type")
const jsxDomType = Symbol.for("jsx-dom:type");
var JsxDomType = /*#__PURE__*/ (function (JsxDomType) {
JsxDomType["ShadowRoot"] = "ShadowRoot"
return JsxDomType
})(JsxDomType || {})
JsxDomType["ShadowRoot"] = "ShadowRoot";
return JsxDomType;
})(JsxDomType || {});
function ShadowRoot(_ref) {
let { children, ref, ...attr } = _ref
let { children, ref, ...attr } = _ref;
return {

@@ -60,9 +64,9 @@ [jsxDomType]: JsxDomType.ShadowRoot,

children,
}
};
}
function isShadowRoot(el) {
return el != null && el[jsxDomType] === JsxDomType.ShadowRoot
return el != null && el[jsxDomType] === JsxDomType.ShadowRoot;
}
const SVGNamespace = "http://www.w3.org/2000/svg"
const SVGNamespace = "http://www.w3.org/2000/svg";

@@ -72,5 +76,4 @@ // https://facebook.github.io/react/docs/jsx-in-depth.html#booleans-null-and-undefined-are-ignored

function isVisibleChild(value) {
return !isBoolean(value) && value != null
return !isBoolean(value) && value != null;
}
const DomTokenList = typeof DOMTokenList !== "undefined" ? DOMTokenList : function () {}

@@ -83,29 +86,30 @@ /**

if (Array.isArray(value)) {
return value.map(className).filter(Boolean).join(" ")
} else if (value instanceof DomTokenList) {
return "" + value
return value.map(className).filter(Boolean).join(" ");
} else if (isObject(value)) {
if (Symbol.iterator in value) {
return className(Array.from(value));
}
return keys(value)
.filter(k => value[k])
.join(" ")
.filter((k) => value[k])
.join(" ");
} else if (isVisibleChild(value)) {
return "" + value
return "" + value;
} else {
return ""
return "";
}
}
function createFactory(tag) {
return createElement.bind(null, tag)
return createElement.bind(null, tag);
}
function Fragment(attr) {
const fragment = document.createDocumentFragment()
appendChild(attr.children, fragment)
return fragment
const fragment = document.createDocumentFragment();
appendChild(attr.children, fragment);
return fragment;
}
class Component {
constructor(props) {
this.props = props
this.props = props;
}
render() {
return null
return null;
}

@@ -119,3 +123,3 @@ }

},
})
});
function initComponentClass(Class, attr, children) {

@@ -125,5 +129,5 @@ attr = {

children,
}
const instance = new Class(attr)
return instance.render()
};
const instance = new Class(attr);
return instance.render();
}

@@ -133,10 +137,10 @@

function jsx(tag, _ref) {
let { children, ...attr } = _ref
let node
let { children, ...attr } = _ref;
let node;
if (isString(tag)) {
node = attr.namespaceURI
? document.createElementNS(attr.namespaceURI, tag)
: document.createElement(tag)
attributes(attr, node)
appendChild(children, node)
: document.createElement(tag);
attributes(attr, node);
appendChild(children, node);

@@ -146,11 +150,13 @@ // Select `option` elements in `select`

if (attr.multiple === true && Array.isArray(attr.value)) {
const values = attr.value.map(value => String(value))
const values = attr.value.map((value) => String(value));
node
.querySelectorAll("option")
.forEach(option => (option.selected = values.includes(option.value)))
.forEach(
(option) => (option.selected = values.includes(option.value)),
);
} else {
node.value = attr.value
node.value = attr.value;
}
}
attachRef(attr.ref, node)
attachRef(attr.ref, node);
} else if (isFunction(tag)) {

@@ -162,3 +168,3 @@ // Custom elements.

...attr,
}
};
}

@@ -170,23 +176,25 @@ node = isComponentClass(tag)

children,
})
});
} else {
throw new TypeError(`Invalid JSX element type: ${tag}`)
throw new TypeError(`Invalid JSX element type: ${tag}`);
}
return node
return node;
}
function createElement(tag, attr) {
for (
var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key2 = 2;
var _len = arguments.length,
children = new Array(_len > 2 ? _len - 2 : 0),
_key2 = 2;
_key2 < _len;
_key2++
) {
children[_key2 - 2] = arguments[_key2]
children[_key2 - 2] = arguments[_key2];
}
if (isString(attr) || Array.isArray(attr)) {
children.unshift(attr)
attr = {}
children.unshift(attr);
attr = {};
}
attr = attr || {}
attr = attr || {};
if (attr.children != null && !children.length) {
;({ children, ...attr } = attr)
({ children, ...attr } = attr);
}

@@ -199,10 +207,10 @@ return jsx(

},
attr.key
)
attr.key,
);
}
function attachRef(ref, node) {
if (isRef(ref)) {
ref.current = node
ref.current = node;
} else if (isFunction(ref)) {
ref(node)
ref(node);
}

@@ -212,13 +220,13 @@ }

if (isArrayLike(child)) {
appendChildren(child, node)
appendChildren(child, node);
} else if (isString(child) || isNumber(child)) {
appendChildToNode(document.createTextNode(child), node)
appendChildToNode(document.createTextNode(child), node);
} else if (child === null) {
appendChildToNode(document.createComment(""), node)
appendChildToNode(document.createComment(""), node);
} else if (isElement(child)) {
appendChildToNode(child, node)
appendChildToNode(child, node);
} else if (isShadowRoot(child)) {
const shadowRoot = node.attachShadow(child.attr)
appendChild(child.children, shadowRoot)
attachRef(child.ref, shadowRoot)
const shadowRoot = node.attachShadow(child.attr);
appendChild(child.children, shadowRoot);
attachRef(child.ref, shadowRoot);
}

@@ -228,11 +236,11 @@ }

for (const child of [...children]) {
appendChild(child, node)
appendChild(child, node);
}
return node
return node;
}
function appendChildToNode(child, node) {
if (node instanceof window.HTMLTemplateElement) {
node.content.appendChild(child)
node.content.appendChild(child);
} else {
node.appendChild(child)
node.appendChild(child);
}

@@ -243,5 +251,5 @@ }

else if (Array.isArray(value)) {
value.forEach(v => style(node, v))
value.forEach((v) => style(node, v));
} else if (isString(value)) {
node.setAttribute("style", value)
node.setAttribute("style", value);
} else if (isObject(value)) {

@@ -252,7 +260,7 @@ forEach(value, (val, key) => {

// and must be assigned via `setProperty`.
node.style.setProperty(key, val)
node.style.setProperty(key, val);
} else {
node.style[key] = val
node.style[key] = val;
}
})
});
}

@@ -263,11 +271,11 @@ }

case "htmlFor":
attr(node, "for", value)
return
attr(node, "for", value);
return;
case "dataset":
forEach(value, (dataValue, dataKey) => {
if (dataValue != null) {
node.dataset[dataKey] = dataValue
node.dataset[dataKey] = dataValue;
}
})
return
});
return;
case "innerHTML":

@@ -277,10 +285,10 @@ case "innerText":

if (isVisibleChild(value)) {
node[key] = value
node[key] = value;
}
return
return;
case "dangerouslySetInnerHTML":
if (isObject(value)) {
node.innerHTML = value["__html"]
node.innerHTML = value["__html"];
}
return
return;
case "value":

@@ -290,51 +298,54 @@ if (value == null || node instanceof window.HTMLSelectElement) {

// for `<select>` apply value after appending `<option>` elements
return
return;
} else if (node instanceof window.HTMLTextAreaElement) {
node.value = value
return
node.value = value;
return;
}
// use attribute for other elements
break
break;
case "spellCheck":
node.spellcheck = value
return
node.spellcheck = value;
return;
case "class":
case "className":
if (isFunction(value)) {
value(node)
value(node);
} else {
attr(node, "class", className(value))
attr(node, "class", className(value));
}
return
return;
case "ref":
case "namespaceURI":
return
return;
case "style":
style(node, value)
return
style(node, value);
return;
case "on":
case "onCapture":
forEach(value, (eventHandler, eventName) => {
node.addEventListener(eventName, eventHandler, key === "onCapture")
})
return
node.addEventListener(eventName, eventHandler, key === "onCapture");
});
return;
// fallthrough
}
if (isFunction(value)) {
if (key[0] === "o" && key[1] === "n") {
let attribute = key.toLowerCase()
const useCapture = attribute.endsWith("capture")
let attribute = key.toLowerCase();
const useCapture = attribute.endsWith("capture");
if (attribute === "ondoubleclick") {
attribute = "ondblclick"
attribute = "ondblclick";
} else if (useCapture && attribute === "ondoubleclickcapture") {
attribute = "ondblclickcapture"
attribute = "ondblclickcapture";
}
if (!useCapture && node[attribute] === null) {
// use property when possible PR #17
node[attribute] = value
node[attribute] = value;
} else if (useCapture) {
node.addEventListener(attribute.substring(2, attribute.length - 7), value, true)
node.addEventListener(
attribute.substring(2, attribute.length - 7),
value,
true,
);
} else {
let eventName
let eventName;
if (attribute in window) {

@@ -345,4 +356,4 @@ // standard event

// so let's add the listener "mouseover", which is all lowercased
const standardEventName = attribute.substring(2)
eventName = standardEventName
const standardEventName = attribute.substring(2);
eventName = standardEventName;
} else {

@@ -354,50 +365,50 @@ // custom event

// except for the first character, we keep the event name case
const customEventName = attribute[2] + key.slice(3)
eventName = customEventName
const customEventName = attribute[2] + key.slice(3);
eventName = customEventName;
}
node.addEventListener(eventName, value)
node.addEventListener(eventName, value);
}
}
} else if (isObject(value)) {
node[key] = value
node[key] = value;
} else if (value === true) {
attr(node, key, "")
attr(node, key, "");
} else if (value !== false && value != null) {
attr(node, key, value)
attr(node, key, value);
}
}
function attr(node, key, value) {
node.setAttribute(key, value)
node.setAttribute(key, value);
}
function attributes(attr, node) {
for (const key of keys(attr)) {
attribute(key, attr[key], node)
attribute(key, attr[key], node);
}
return node
return node;
}
function useText(initialValue) {
const text = new Text()
const text = new Text();
Object.defineProperty(text, "toString", {
value() {
return this.textContent
return this.textContent;
},
})
});
function setText(value) {
text.textContent = value
text.textContent = value;
}
if (initialValue != null) {
setText(initialValue)
setText(initialValue);
}
return [text, setText]
return [text, setText];
}
function useClassList(initialValue) {
const div = document.createElement("div")
const div = document.createElement("div");
if (initialValue != null) {
div.className = className(initialValue)
div.className = className(initialValue);
}
let list = div.classList
let list = div.classList;
function ClassList(value) {
value.setAttribute("class", list.value)
list = value.classList
value.setAttribute("class", list.value);
list = value.classList;
}

@@ -408,72 +419,76 @@ Object.defineProperties(

get size() {
return list.length
return list.length;
},
get value() {
return list.value
return list.value;
},
add() {
list.add(...arguments)
list.add(...arguments);
},
remove() {
list.remove(...arguments)
list.remove(...arguments);
},
toggle(token, force) {
list.toggle(token, force)
list.toggle(token, force);
},
contains(token) {
return list.contains(token)
return list.contains(token);
},
})
)
return ClassList
}),
);
return ClassList;
}
function useMemo(factory) {
return factory()
return factory();
}
function forwardRef(render) {
return _ref => {
let { ref, ...props } = _ref
return render(props, ref ?? createRef())
}
return (_ref) => {
let { ref, ...props } = _ref;
return render(props, ref ?? createRef());
};
}
function useImperativeHandle(ref, init) {
attachRef(ref, init())
attachRef(ref, init());
}
const cache = /* @__PURE__ */ new Map()
const createStyledComponent = name =>
const cache = /* @__PURE__ */ new Map();
const createStyledComponent = (name) =>
function (list) {
for (
var _len = arguments.length, interpolations = new Array(_len > 1 ? _len - 1 : 0), _key = 1;
var _len = arguments.length,
interpolations = new Array(_len > 1 ? _len - 1 : 0),
_key = 1;
_key < _len;
_key++
) {
interpolations[_key - 1] = arguments[_key]
interpolations[_key - 1] = arguments[_key];
}
return _ref => {
let { style, ...props } = _ref
const lastIndex = list.length - 1
return (_ref) => {
let { style, ...props } = _ref;
const lastIndex = list.length - 1;
const css =
list.slice(0, lastIndex).reduce((p, s, i) => p + s + interpolations[i](props), "") +
list[lastIndex]
list
.slice(0, lastIndex)
.reduce((p, s, i) => p + s + interpolations[i](props), "") +
list[lastIndex];
return createElement(name, {
style: [css, style],
...props,
})
}
}
const baseStyled = customComponent => createStyledComponent(customComponent)
});
};
};
const baseStyled = (customComponent) => createStyledComponent(customComponent);
const styled = /* @__PURE__ */ new Proxy(baseStyled, {
get(_, name) {
return setIfAbsent(cache, name, () => createStyledComponent(name))
return setIfAbsent(cache, name, () => createStyledComponent(name));
},
})
});
function setIfAbsent(map, key, getValue) {
if (map.has(key)) {
return map.get(key)
return map.get(key);
} else {
const value = getValue(key)
map.set(key, value)
return value
const value = getValue(key);
map.set(key, value);
return value;
}

@@ -488,10 +503,10 @@ }

ShadowRoot,
}
};
function preventDefault(event) {
event.preventDefault()
return event
event.preventDefault();
return event;
}
function stopPropagation(event) {
event.stopPropagation()
return event
event.stopPropagation();
return event;
}

@@ -526,2 +541,2 @@

useText,
}
};
/* eslint-disable */
export { Fragment, jsx, jsx as jsxDEV, jsx as jsxs } from "jsx-dom/min"
export { Fragment, jsx, jsx as jsxDEV, jsx as jsxs } from "jsx-dom/min";
{
"name": "jsx-dom",
"version": "8.1.2",
"version": "8.1.3",
"description": "JSX to document.createElement.",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc