Comparing version 6.4.13 to 6.4.14-beta.0
"use strict" | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true, | ||
}) | ||
var __assign = Object.assign | ||
Object.defineProperty(exports, "__esModule", { value: true }) | ||
function __rest(s, e) { | ||
var t = {} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {} | ||
var target = {} | ||
var sourceKeys = Object.keys(source) | ||
var key, i | ||
for (var p in s) | ||
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p] | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i] | ||
if (excluded.indexOf(key) >= 0) continue | ||
target[key] = source[key] | ||
} | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]] | ||
} | ||
return t | ||
return target | ||
} | ||
var keys = Object.keys | ||
const keys = Object.keys | ||
function identity(value) { | ||
return value | ||
} | ||
function isBoolean(val) { | ||
return typeof val === "boolean" | ||
} | ||
function isElement(val) { | ||
return val && typeof val.nodeType === "number" | ||
} | ||
function isString(val) { | ||
return typeof val === "string" | ||
} | ||
function isNumber(val) { | ||
return typeof val === "number" | ||
} | ||
function isObject(val) { | ||
return typeof val === "object" ? val !== null : isFunction(val) | ||
} | ||
function isFunction(val) { | ||
return typeof val === "function" | ||
} | ||
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" | ||
} | ||
@@ -61,3 +51,2 @@ | ||
} | ||
function isRef(maybeRef) { | ||
@@ -68,5 +57,5 @@ return isObject(maybeRef) && "current" in maybeRef | ||
function useText(initialValue) { | ||
var text = new Text() | ||
const text = new Text() | ||
Object.defineProperty(text, "toString", { | ||
value: function() { | ||
value() { | ||
return this.textContent | ||
@@ -87,7 +76,6 @@ }, | ||
var SVGNamespace = "http://www.w3.org/2000/svg" | ||
const SVGNamespace = "http://www.w3.org/2000/svg" | ||
var index = { | ||
createElement: createElement, | ||
createElement, | ||
} | ||
function preventDefault(event) { | ||
@@ -97,3 +85,2 @@ event.preventDefault() | ||
} | ||
function stopPropagation(event) { | ||
@@ -116,5 +103,3 @@ event.stopPropagation() | ||
return keys(value) | ||
.filter(function(k) { | ||
return value[k] | ||
}) | ||
.filter(k => value[k]) | ||
.join(" ") | ||
@@ -127,29 +112,20 @@ } else if (isVisibleChild(value)) { | ||
} | ||
function createFactory(tag) { | ||
return createElement.bind(null, tag) | ||
} | ||
function Fragment(attr) { | ||
var fragment = document.createDocumentFragment() | ||
const fragment = document.createDocumentFragment() | ||
appendChildren(attr.children, fragment) | ||
return fragment | ||
} | ||
function createElement(tag, attr) { | ||
var children = [] | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
children[_i - 2] = arguments[_i] | ||
} | ||
var _a | ||
function createElement(tag, attr, ...children) { | ||
attr = attr || {} | ||
if (attr.children != null && !children.length) { | ||
;(_a = attr), ((children = _a.children), _a), (attr = __rest(_a, ["children"])) | ||
var _attr = attr | ||
;({ children } = _attr) | ||
attr = _objectWithoutPropertiesLoose(_attr, ["children"]) | ||
} | ||
var node | ||
let node | ||
@@ -164,8 +140,8 @@ if (isString(tag)) { | ||
if (isObject(tag.defaultProps)) { | ||
attr = __assign(__assign({}, tag.defaultProps), attr) | ||
attr = Object.assign({}, tag.defaultProps, {}, attr) | ||
} | ||
node = tag( | ||
__assign(__assign({}, attr), { | ||
children: children, | ||
Object.assign({}, attr, { | ||
children, | ||
}) | ||
@@ -197,4 +173,3 @@ ) | ||
function appendChildren(children, node) { | ||
for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { | ||
var child = children_1[_i] | ||
for (const child of children) { | ||
appendChild(child, node) | ||
@@ -209,9 +184,8 @@ } | ||
case "htmlFor": | ||
node.setAttribute("for", value) | ||
attr(node, "for", value) | ||
return | ||
case "dataset": | ||
for (var _i = 0, _a = keys(value || {}); _i < _a.length; _i++) { | ||
var dataKey = _a[_i] | ||
var dataValue = value[dataKey] | ||
for (const dataKey of keys(value || {})) { | ||
const dataValue = value[dataKey] | ||
@@ -237,3 +211,3 @@ if (dataValue != null) { | ||
case "className": | ||
node.setAttribute("class", className(value)) | ||
attr(node, "class", className(value)) | ||
return | ||
@@ -257,11 +231,14 @@ | ||
} else if (value === true) { | ||
node.setAttribute(key, "") | ||
attr(node, key, "") | ||
} else if (value !== false && value != null) { | ||
node.setAttribute(key, value) | ||
attr(node, key, value) | ||
} | ||
} | ||
function attr(node, key, value) { | ||
node.setAttribute(key, value) | ||
} | ||
function attributes(attr, node) { | ||
for (var _i = 0, _a = keys(attr); _i < _a.length; _i++) { | ||
var key = _a[_i] | ||
for (const key of keys(attr)) { | ||
attribute(key, attr[key], node) | ||
@@ -274,3 +251,3 @@ } | ||
exports.Fragment = Fragment | ||
exports.SVGNamespace = "http://www.w3.org/2000/svg" | ||
exports.SVGNamespace = SVGNamespace | ||
exports.className = className | ||
@@ -282,4 +259,6 @@ exports.createElement = createElement | ||
exports.h = createElement | ||
exports.memo = identity | ||
exports.preventDefault = preventDefault | ||
exports.stopPropagation = stopPropagation | ||
exports.useRef = createRef | ||
exports.useText = useText |
108
lib/index.js
@@ -1,49 +0,40 @@ | ||
var __assign = Object.assign | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {} | ||
var target = {} | ||
var sourceKeys = Object.keys(source) | ||
var key, i | ||
function __rest(s, e) { | ||
var t = {} | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i] | ||
if (excluded.indexOf(key) >= 0) continue | ||
target[key] = source[key] | ||
} | ||
for (var p in s) | ||
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p] | ||
return target | ||
} | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]] | ||
} | ||
return t | ||
const keys = Object.keys | ||
function identity(value) { | ||
return value | ||
} | ||
var keys = Object.keys | ||
function isBoolean(val) { | ||
return typeof val === "boolean" | ||
} | ||
function isElement(val) { | ||
return val && typeof val.nodeType === "number" | ||
} | ||
function isString(val) { | ||
return typeof val === "string" | ||
} | ||
function isNumber(val) { | ||
return typeof val === "number" | ||
} | ||
function isObject(val) { | ||
return typeof val === "object" ? val !== null : isFunction(val) | ||
} | ||
function isFunction(val) { | ||
return typeof val === "function" | ||
} | ||
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" | ||
} | ||
@@ -56,3 +47,2 @@ | ||
} | ||
function isRef(maybeRef) { | ||
@@ -63,5 +53,5 @@ return isObject(maybeRef) && "current" in maybeRef | ||
function useText(initialValue) { | ||
var text = new Text() | ||
const text = new Text() | ||
Object.defineProperty(text, "toString", { | ||
value: function() { | ||
value() { | ||
return this.textContent | ||
@@ -82,7 +72,6 @@ }, | ||
var SVGNamespace = "http://www.w3.org/2000/svg" | ||
const SVGNamespace = "http://www.w3.org/2000/svg" | ||
var index = { | ||
createElement: createElement, | ||
createElement, | ||
} | ||
function preventDefault(event) { | ||
@@ -92,3 +81,2 @@ event.preventDefault() | ||
} | ||
function stopPropagation(event) { | ||
@@ -111,5 +99,3 @@ event.stopPropagation() | ||
return keys(value) | ||
.filter(function(k) { | ||
return value[k] | ||
}) | ||
.filter(k => value[k]) | ||
.join(" ") | ||
@@ -122,29 +108,20 @@ } else if (isVisibleChild(value)) { | ||
} | ||
function createFactory(tag) { | ||
return createElement.bind(null, tag) | ||
} | ||
function Fragment(attr) { | ||
var fragment = document.createDocumentFragment() | ||
const fragment = document.createDocumentFragment() | ||
appendChildren(attr.children, fragment) | ||
return fragment | ||
} | ||
function createElement(tag, attr) { | ||
var children = [] | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
children[_i - 2] = arguments[_i] | ||
} | ||
var _a | ||
function createElement(tag, attr, ...children) { | ||
attr = attr || {} | ||
if (attr.children != null && !children.length) { | ||
;(_a = attr), ((children = _a.children), _a), (attr = __rest(_a, ["children"])) | ||
var _attr = attr | ||
;({ children } = _attr) | ||
attr = _objectWithoutPropertiesLoose(_attr, ["children"]) | ||
} | ||
var node | ||
let node | ||
@@ -159,8 +136,8 @@ if (isString(tag)) { | ||
if (isObject(tag.defaultProps)) { | ||
attr = __assign(__assign({}, tag.defaultProps), attr) | ||
attr = Object.assign({}, tag.defaultProps, {}, attr) | ||
} | ||
node = tag( | ||
__assign(__assign({}, attr), { | ||
children: children, | ||
Object.assign({}, attr, { | ||
children, | ||
}) | ||
@@ -192,4 +169,3 @@ ) | ||
function appendChildren(children, node) { | ||
for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { | ||
var child = children_1[_i] | ||
for (const child of children) { | ||
appendChild(child, node) | ||
@@ -204,9 +180,8 @@ } | ||
case "htmlFor": | ||
node.setAttribute("for", value) | ||
attr(node, "for", value) | ||
return | ||
case "dataset": | ||
for (var _i = 0, _a = keys(value || {}); _i < _a.length; _i++) { | ||
var dataKey = _a[_i] | ||
var dataValue = value[dataKey] | ||
for (const dataKey of keys(value || {})) { | ||
const dataValue = value[dataKey] | ||
@@ -232,3 +207,3 @@ if (dataValue != null) { | ||
case "className": | ||
node.setAttribute("class", className(value)) | ||
attr(node, "class", className(value)) | ||
return | ||
@@ -252,11 +227,14 @@ | ||
} else if (value === true) { | ||
node.setAttribute(key, "") | ||
attr(node, key, "") | ||
} else if (value !== false && value != null) { | ||
node.setAttribute(key, value) | ||
attr(node, key, value) | ||
} | ||
} | ||
function attr(node, key, value) { | ||
node.setAttribute(key, value) | ||
} | ||
function attributes(attr, node) { | ||
for (var _i = 0, _a = keys(attr); _i < _a.length; _i++) { | ||
var key = _a[_i] | ||
for (const key of keys(attr)) { | ||
attribute(key, attr[key], node) | ||
@@ -277,5 +255,7 @@ } | ||
createElement as h, | ||
identity as memo, | ||
preventDefault, | ||
stopPropagation, | ||
createRef as useRef, | ||
useText, | ||
} |
"use strict" | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true, | ||
}) | ||
var __assign = Object.assign | ||
Object.defineProperty(exports, "__esModule", { value: true }) | ||
function __rest(s, e) { | ||
var t = {} | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {} | ||
var target = {} | ||
var sourceKeys = Object.keys(source) | ||
var key, i | ||
for (var p in s) | ||
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p] | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i] | ||
if (excluded.indexOf(key) >= 0) continue | ||
target[key] = source[key] | ||
} | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]] | ||
} | ||
return t | ||
return target | ||
} | ||
var keys = Object.keys | ||
const keys = Object.keys | ||
function identity(value) { | ||
return value | ||
} | ||
function isBoolean(val) { | ||
return typeof val === "boolean" | ||
} | ||
function isElement(val) { | ||
return val && typeof val.nodeType === "number" | ||
} | ||
function isString(val) { | ||
return typeof val === "string" | ||
} | ||
function isNumber(val) { | ||
return typeof val === "number" | ||
} | ||
function isObject(val) { | ||
return typeof val === "object" ? val !== null : isFunction(val) | ||
} | ||
function isFunction(val) { | ||
return typeof val === "function" | ||
} | ||
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" | ||
} | ||
@@ -61,3 +51,2 @@ | ||
} | ||
function isRef(maybeRef) { | ||
@@ -68,5 +57,5 @@ return isObject(maybeRef) && "current" in maybeRef | ||
function useText(initialValue) { | ||
var text = new Text() | ||
const text = new Text() | ||
Object.defineProperty(text, "toString", { | ||
value: function() { | ||
value() { | ||
return this.textContent | ||
@@ -87,9 +76,8 @@ }, | ||
var SVGNamespace = "http://www.w3.org/2000/svg" | ||
var XLinkNamespace = "http://www.w3.org/1999/xlink" | ||
var 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" | ||
var index = { | ||
createElement: createElement, | ||
createElement, | ||
} | ||
function preventDefault(event) { | ||
@@ -99,3 +87,2 @@ event.preventDefault() | ||
} | ||
function stopPropagation(event) { | ||
@@ -118,5 +105,3 @@ event.stopPropagation() | ||
return keys(value) | ||
.filter(function(k) { | ||
return value[k] | ||
}) | ||
.filter(k => value[k]) | ||
.join(" ") | ||
@@ -129,4 +114,3 @@ } else if (isVisibleChild(value)) { | ||
} | ||
var svg = { | ||
const svg = { | ||
animate: 0, | ||
@@ -187,26 +171,15 @@ circle: 0, | ||
} | ||
function createFactory(tag) { | ||
return createElement.bind(null, tag) | ||
} | ||
function Fragment(attr) { | ||
var fragment = document.createDocumentFragment() | ||
const fragment = document.createDocumentFragment() | ||
appendChildren(attr.children, fragment) | ||
return fragment | ||
} | ||
function createElement(tag, attr) { | ||
var children = [] | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
children[_i - 2] = arguments[_i] | ||
} | ||
var _a | ||
function createElement(tag, attr, ...children) { | ||
attr = attr || {} | ||
if (!attr.namespaceURI && svg[tag] === 0) { | ||
attr = __assign(__assign({}, attr), { | ||
attr = Object.assign({}, attr, { | ||
namespaceURI: SVGNamespace, | ||
@@ -217,6 +190,8 @@ }) | ||
if (attr.children != null && !children.length) { | ||
;(_a = attr), ((children = _a.children), _a), (attr = __rest(_a, ["children"])) | ||
var _attr = attr | ||
;({ children } = _attr) | ||
attr = _objectWithoutPropertiesLoose(_attr, ["children"]) | ||
} | ||
var node | ||
let node | ||
@@ -231,8 +206,8 @@ if (isString(tag)) { | ||
if (isObject(tag.defaultProps)) { | ||
attr = __assign(__assign({}, tag.defaultProps), attr) | ||
attr = Object.assign({}, tag.defaultProps, {}, attr) | ||
} | ||
node = tag( | ||
__assign(__assign({}, attr), { | ||
children: children, | ||
Object.assign({}, attr, { | ||
children, | ||
}) | ||
@@ -264,4 +239,3 @@ ) | ||
function appendChildren(children, node) { | ||
for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { | ||
var child = children_1[_i] | ||
for (const child of children) { | ||
appendChild(child, node) | ||
@@ -274,30 +248,26 @@ } | ||
function normalizeAttribute(s) { | ||
return s.replace(/[A-Z\d]/g, function(match) { | ||
return ":" + match.toLowerCase() | ||
}) | ||
return s.replace(/[A-Z\d]/g, match => ":" + match.toLowerCase()) | ||
} | ||
function attribute(key, value, node) { | ||
{ | ||
switch (key) { | ||
case "xlinkActuate": | ||
case "xlinkArcrole": | ||
case "xlinkHref": | ||
case "xlinkRole": | ||
case "xlinkShow": | ||
case "xlinkTitle": | ||
case "xlinkType": | ||
node.setAttributeNS(XLinkNamespace, normalizeAttribute(key), value) | ||
return | ||
switch (key) { | ||
case "xlinkActuate": | ||
case "xlinkArcrole": | ||
case "xlinkHref": | ||
case "xlinkRole": | ||
case "xlinkShow": | ||
case "xlinkTitle": | ||
case "xlinkType": | ||
attrNS(node, XLinkNamespace, normalizeAttribute(key), value) | ||
return | ||
case "xmlnsXlink": | ||
node.setAttribute(normalizeAttribute(key), value) | ||
return | ||
case "xmlnsXlink": | ||
attr(node, normalizeAttribute(key), value) | ||
return | ||
case "xmlBase": | ||
case "xmlLang": | ||
case "xmlSpace": | ||
node.setAttributeNS(XMLNamespace, normalizeAttribute(key), value) | ||
return | ||
} | ||
case "xmlBase": | ||
case "xmlLang": | ||
case "xmlSpace": | ||
attrNS(node, XMLNamespace, normalizeAttribute(key), value) | ||
return | ||
} | ||
@@ -307,9 +277,8 @@ | ||
case "htmlFor": | ||
node.setAttribute("for", value) | ||
attr(node, "for", value) | ||
return | ||
case "dataset": | ||
for (var _i = 0, _a = keys(value || {}); _i < _a.length; _i++) { | ||
var dataKey = _a[_i] | ||
var dataValue = value[dataKey] | ||
for (const dataKey of keys(value || {})) { | ||
const dataValue = value[dataKey] | ||
@@ -335,3 +304,3 @@ if (dataValue != null) { | ||
case "className": | ||
node.setAttribute("class", className(value)) | ||
attr(node, "class", className(value)) | ||
return | ||
@@ -355,11 +324,18 @@ | ||
} else if (value === true) { | ||
node.setAttribute(key, "") | ||
attr(node, key, "") | ||
} else if (value !== false && value != null) { | ||
node.setAttribute(key, value) | ||
attr(node, key, value) | ||
} | ||
} | ||
function attr(node, key, value) { | ||
node.setAttribute(key, value) | ||
} | ||
function attrNS(node, namespace, key, value) { | ||
node.setAttributeNS(namespace, key, value) | ||
} | ||
function attributes(attr, node) { | ||
for (var _i = 0, _a = keys(attr); _i < _a.length; _i++) { | ||
var key = _a[_i] | ||
for (const key of keys(attr)) { | ||
attribute(key, attr[key], node) | ||
@@ -372,3 +348,3 @@ } | ||
exports.Fragment = Fragment | ||
exports.SVGNamespace = "http://www.w3.org/2000/svg" | ||
exports.SVGNamespace = SVGNamespace | ||
exports.className = className | ||
@@ -380,4 +356,6 @@ exports.createElement = createElement | ||
exports.h = createElement | ||
exports.memo = identity | ||
exports.preventDefault = preventDefault | ||
exports.stopPropagation = stopPropagation | ||
exports.useRef = createRef | ||
exports.useText = useText |
163
lib/svg.js
@@ -1,49 +0,40 @@ | ||
var __assign = Object.assign | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {} | ||
var target = {} | ||
var sourceKeys = Object.keys(source) | ||
var key, i | ||
function __rest(s, e) { | ||
var t = {} | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i] | ||
if (excluded.indexOf(key) >= 0) continue | ||
target[key] = source[key] | ||
} | ||
for (var p in s) | ||
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p] | ||
return target | ||
} | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]] | ||
} | ||
return t | ||
const keys = Object.keys | ||
function identity(value) { | ||
return value | ||
} | ||
var keys = Object.keys | ||
function isBoolean(val) { | ||
return typeof val === "boolean" | ||
} | ||
function isElement(val) { | ||
return val && typeof val.nodeType === "number" | ||
} | ||
function isString(val) { | ||
return typeof val === "string" | ||
} | ||
function isNumber(val) { | ||
return typeof val === "number" | ||
} | ||
function isObject(val) { | ||
return typeof val === "object" ? val !== null : isFunction(val) | ||
} | ||
function isFunction(val) { | ||
return typeof val === "function" | ||
} | ||
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" | ||
} | ||
@@ -56,3 +47,2 @@ | ||
} | ||
function isRef(maybeRef) { | ||
@@ -63,5 +53,5 @@ return isObject(maybeRef) && "current" in maybeRef | ||
function useText(initialValue) { | ||
var text = new Text() | ||
const text = new Text() | ||
Object.defineProperty(text, "toString", { | ||
value: function() { | ||
value() { | ||
return this.textContent | ||
@@ -82,9 +72,8 @@ }, | ||
var SVGNamespace = "http://www.w3.org/2000/svg" | ||
var XLinkNamespace = "http://www.w3.org/1999/xlink" | ||
var 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" | ||
var index = { | ||
createElement: createElement, | ||
createElement, | ||
} | ||
function preventDefault(event) { | ||
@@ -94,3 +83,2 @@ event.preventDefault() | ||
} | ||
function stopPropagation(event) { | ||
@@ -113,5 +101,3 @@ event.stopPropagation() | ||
return keys(value) | ||
.filter(function(k) { | ||
return value[k] | ||
}) | ||
.filter(k => value[k]) | ||
.join(" ") | ||
@@ -124,4 +110,3 @@ } else if (isVisibleChild(value)) { | ||
} | ||
var svg = { | ||
const svg = { | ||
animate: 0, | ||
@@ -182,26 +167,15 @@ circle: 0, | ||
} | ||
function createFactory(tag) { | ||
return createElement.bind(null, tag) | ||
} | ||
function Fragment(attr) { | ||
var fragment = document.createDocumentFragment() | ||
const fragment = document.createDocumentFragment() | ||
appendChildren(attr.children, fragment) | ||
return fragment | ||
} | ||
function createElement(tag, attr) { | ||
var children = [] | ||
for (var _i = 2; _i < arguments.length; _i++) { | ||
children[_i - 2] = arguments[_i] | ||
} | ||
var _a | ||
function createElement(tag, attr, ...children) { | ||
attr = attr || {} | ||
if (!attr.namespaceURI && svg[tag] === 0) { | ||
attr = __assign(__assign({}, attr), { | ||
attr = Object.assign({}, attr, { | ||
namespaceURI: SVGNamespace, | ||
@@ -212,6 +186,8 @@ }) | ||
if (attr.children != null && !children.length) { | ||
;(_a = attr), ((children = _a.children), _a), (attr = __rest(_a, ["children"])) | ||
var _attr = attr | ||
;({ children } = _attr) | ||
attr = _objectWithoutPropertiesLoose(_attr, ["children"]) | ||
} | ||
var node | ||
let node | ||
@@ -226,8 +202,8 @@ if (isString(tag)) { | ||
if (isObject(tag.defaultProps)) { | ||
attr = __assign(__assign({}, tag.defaultProps), attr) | ||
attr = Object.assign({}, tag.defaultProps, {}, attr) | ||
} | ||
node = tag( | ||
__assign(__assign({}, attr), { | ||
children: children, | ||
Object.assign({}, attr, { | ||
children, | ||
}) | ||
@@ -259,4 +235,3 @@ ) | ||
function appendChildren(children, node) { | ||
for (var _i = 0, children_1 = children; _i < children_1.length; _i++) { | ||
var child = children_1[_i] | ||
for (const child of children) { | ||
appendChild(child, node) | ||
@@ -269,30 +244,26 @@ } | ||
function normalizeAttribute(s) { | ||
return s.replace(/[A-Z\d]/g, function(match) { | ||
return ":" + match.toLowerCase() | ||
}) | ||
return s.replace(/[A-Z\d]/g, match => ":" + match.toLowerCase()) | ||
} | ||
function attribute(key, value, node) { | ||
{ | ||
switch (key) { | ||
case "xlinkActuate": | ||
case "xlinkArcrole": | ||
case "xlinkHref": | ||
case "xlinkRole": | ||
case "xlinkShow": | ||
case "xlinkTitle": | ||
case "xlinkType": | ||
node.setAttributeNS(XLinkNamespace, normalizeAttribute(key), value) | ||
return | ||
switch (key) { | ||
case "xlinkActuate": | ||
case "xlinkArcrole": | ||
case "xlinkHref": | ||
case "xlinkRole": | ||
case "xlinkShow": | ||
case "xlinkTitle": | ||
case "xlinkType": | ||
attrNS(node, XLinkNamespace, normalizeAttribute(key), value) | ||
return | ||
case "xmlnsXlink": | ||
node.setAttribute(normalizeAttribute(key), value) | ||
return | ||
case "xmlnsXlink": | ||
attr(node, normalizeAttribute(key), value) | ||
return | ||
case "xmlBase": | ||
case "xmlLang": | ||
case "xmlSpace": | ||
node.setAttributeNS(XMLNamespace, normalizeAttribute(key), value) | ||
return | ||
} | ||
case "xmlBase": | ||
case "xmlLang": | ||
case "xmlSpace": | ||
attrNS(node, XMLNamespace, normalizeAttribute(key), value) | ||
return | ||
} | ||
@@ -302,9 +273,8 @@ | ||
case "htmlFor": | ||
node.setAttribute("for", value) | ||
attr(node, "for", value) | ||
return | ||
case "dataset": | ||
for (var _i = 0, _a = keys(value || {}); _i < _a.length; _i++) { | ||
var dataKey = _a[_i] | ||
var dataValue = value[dataKey] | ||
for (const dataKey of keys(value || {})) { | ||
const dataValue = value[dataKey] | ||
@@ -330,3 +300,3 @@ if (dataValue != null) { | ||
case "className": | ||
node.setAttribute("class", className(value)) | ||
attr(node, "class", className(value)) | ||
return | ||
@@ -350,11 +320,18 @@ | ||
} else if (value === true) { | ||
node.setAttribute(key, "") | ||
attr(node, key, "") | ||
} else if (value !== false && value != null) { | ||
node.setAttribute(key, value) | ||
attr(node, key, value) | ||
} | ||
} | ||
function attr(node, key, value) { | ||
node.setAttribute(key, value) | ||
} | ||
function attrNS(node, namespace, key, value) { | ||
node.setAttributeNS(namespace, key, value) | ||
} | ||
function attributes(attr, node) { | ||
for (var _i = 0, _a = keys(attr); _i < _a.length; _i++) { | ||
var key = _a[_i] | ||
for (const key of keys(attr)) { | ||
attribute(key, attr[key], node) | ||
@@ -375,5 +352,7 @@ } | ||
createElement as h, | ||
identity as memo, | ||
preventDefault, | ||
stopPropagation, | ||
createRef as useRef, | ||
useText, | ||
} |
{ | ||
"name": "jsx-dom", | ||
"version": "6.4.13", | ||
"version": "6.4.14-beta.0", | ||
"description": "JSX to document.createElement.", | ||
@@ -11,5 +11,6 @@ "main": "lib/index.cjs.js", | ||
"pretest": "npm run build", | ||
"postinstall": "patch-package", | ||
"postpublish": "rm lib/*.js", | ||
"prepublishOnly": "yarn build && yarn test", | ||
"test": "nyc --reporter=html mocha test/test.tsx --require test/register" | ||
"test": "nyc --reporter=html mocha test/test-*.tsx --require test/register" | ||
}, | ||
@@ -23,10 +24,17 @@ "keywords": [ | ||
"license": "BSD-3-Clause", | ||
"dependencies": { | ||
"csstype": "^2.6.9", | ||
"tslib": "^1.11.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.8.7", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.8.3", | ||
"@babel/preset-typescript": "^7.8.3", | ||
"@rollup/plugin-node-resolve": "^7.1.1", | ||
"@rollup/plugin-replace": "^2.3.1", | ||
"@types/babel__core": "^7.1.6", | ||
"@types/chai": "^4.2.10", | ||
"@types/chai": "^4.2.11", | ||
"@types/jsdom": "^16.1.0", | ||
"@types/mocha": "^7.0.2", | ||
"@types/node": "^13.9.0", | ||
"@types/node": "^13.9.1", | ||
"@types/prop-types": "^15.7.3", | ||
@@ -37,11 +45,11 @@ "babel-preset-minify": "^0.5.1", | ||
"fs-extra": "^8.1.0", | ||
"jsdom": "^16.2.0", | ||
"jsdom": "^16.2.1", | ||
"mocha": "^7.1.0", | ||
"nyc": "^15.0.0", | ||
"patch-package": "^6.2.1", | ||
"prettier": "^1.19.1", | ||
"rollup": "^2.0.2", | ||
"rollup": "^2.0.6", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-prettier": "^0.6.0", | ||
"rollup-typescript": "^1.2.1", | ||
"ts-node": "^8.6.2", | ||
"tslib": "^1.11.1", | ||
"typescript": "^3.8.3" | ||
@@ -59,3 +67,3 @@ }, | ||
"tabWidth": 2, | ||
"printWidth": 85, | ||
"printWidth": 95, | ||
"semi": false, | ||
@@ -62,0 +70,0 @@ "singleQuote": false, |
# jsx-dom | ||
<!-- prettier-ignore --> | ||
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) | ||
@@ -10,3 +9,3 @@ [![build status](https://travis-ci.org/proteriax/jsx-dom.svg?branch=master)](https://travis-ci.org/proteriax/jsx-dom) | ||
Use JSX for creating DOM elements. | ||
Use JSX for creating DOM elements. With ES Module support. | ||
@@ -165,13 +164,2 @@ ## Installation | ||
## Goodies | ||
Three extra functions and one constant are provided by this package: | ||
1. `preventDefault(event: Event): Event` | ||
2. `stopPropagation(event: Event): Event` | ||
3. `createFactory(component: string | (props) => JSX.Element)` | ||
4. `SVGNamespace` is the `namespaceURI` string for SVG Elements. | ||
5. `className` function. | ||
6. `import { HTML } from "jsx-dom"` contains short type aliases for HTML elements | ||
## `useText` | ||
@@ -192,2 +180,38 @@ | ||
## Goodies | ||
Three extra functions and one constant are provided by this package: | ||
```ts | ||
declare module "jsx-dom" { | ||
export function preventDefault(event: Event): Event | ||
export function stopPropagation(event: Event): Event | ||
/** `namespaceURI` string for SVG Elements. */ | ||
export const SVGNamespace: string | ||
export function className(value: any): string | ||
/** Short type aliases for HTML elements */ | ||
export namespace HTML { | ||
type Button = HTMLButtonElement | ||
type Div = HTMLDivElement | ||
... | ||
} | ||
} | ||
``` | ||
## API | ||
The following functions are included for compatibility with React API: | ||
```ts | ||
function createFactory(component: string): (props: object) => JSX.Element | ||
``` | ||
The following functions **will** ignore `deps`, and are only useful if you are | ||
migrating from/to React. | ||
```ts | ||
function useMemo<T>(fn: () => T, deps: any[]): T | ||
function useCallback<T extends Function>(fn: T, deps: any[]): T | ||
``` | ||
## Browser Support | ||
@@ -194,0 +218,0 @@ |
/** | ||
* Adapted from React’s TypeScript definition from DefinitelyTyped. | ||
* Adapted from React TypeScript definition from DefinitelyTyped. | ||
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts | ||
@@ -4,0 +4,0 @@ */ |
Sorry, the diff of this file is too big to display
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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
223
100102
2
25
2857
1
1
+ Addedcsstype@^2.6.9
+ Addedtslib@^1.11.1
+ Addedcsstype@2.6.21(transitive)
+ Addedtslib@1.14.1(transitive)