Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gera2ld/jsx-dom

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gera2ld/jsx-dom - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

52

dist/index.js

@@ -1,2 +0,2 @@

/*! @gera2ld/jsx-dom v2.2.1 | ISC License */
/*! @gera2ld/jsx-dom v2.2.2 | ISC License */
(function (exports) {

@@ -18,7 +18,3 @@ 'use strict';

const isRenderFunction = c => (c == null ? void 0 : c.vtype) === VTYPE_FUNCTION;
function h(type, props) {
for (var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
children[_key - 2] = arguments[_key];
}
function h(type, props, ...children) {
props = Object.assign({}, props, {

@@ -54,7 +50,7 @@ children: children.length === 1 ? children[0] : children

if (key === 'key' || key === 'children' || key === 'ref') continue;
if (key === 'dangerouslySetInnerHTML') {
domElement.innerHTML = props[key].__html;
} else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText') {
domElement[key] = props[key];
} else if (key === 'innerHTML' || key === 'textContent' || key === 'innerText' || key === 'value' && ['textarea', 'select'].includes(domElement.tagName)) {
const value = props[key];
if (value != null) domElement[key] = value;
} else if (key.startsWith('on')) {

@@ -71,6 +67,4 @@ domElement[key.toLowerCase()] = props[key];

};
function setDOMAttribute(el, attr, value, isSVG) {
attr = attrMap[attr] || attr;
if (value === true) {

@@ -82,3 +76,2 @@ el.setAttribute(attr, '');

const namespace = isSVG ? NS_ATTRS[attr] : undefined;
if (namespace !== undefined) {

@@ -91,24 +84,15 @@ el.setAttributeNS(namespace, attr, value);

}
function flatten(arr) {
return arr.reduce((prev, item) => prev.concat(item), []);
}
function mountChildren(children, env) {
return Array.isArray(children) ? flatten(children.map(child => mountChildren(child, env))) : mount(children, env);
}
function mount(vnode, env) {
if (env === void 0) {
env = DEFAULT_ENV;
}
function mount(vnode, env = DEFAULT_ENV) {
if (vnode == null || typeof vnode === 'boolean') {
return null;
}
if (vnode instanceof Node) {
return vnode;
}
if (isRenderFunction(vnode)) {

@@ -119,6 +103,4 @@ const {

} = vnode;
if (type === Fragment) {
const node = document.createDocumentFragment();
if (props.children) {

@@ -128,14 +110,10 @@ const children = mountChildren(props.children, env);

}
return node;
}
const childVNode = type(props);
return mount(childVNode, env);
}
if (isLeaf(vnode)) {
return document.createTextNode("" + vnode);
return document.createTextNode(`${vnode}`);
}
if (isElement(vnode)) {

@@ -147,3 +125,2 @@ let node;

} = vnode;
if (!env.isSvg && type === 'svg') {

@@ -154,3 +131,2 @@ env = Object.assign({}, env, {

}
if (!env.isSvg) {

@@ -161,8 +137,5 @@ node = document.createElement(type);

}
mountAttributes(node, props, env);
if (props.children) {
let childEnv = env;
if (env.isSvg && type === 'foreignObject') {

@@ -173,7 +146,5 @@ childEnv = Object.assign({}, childEnv, {

}
const children = mountChildren(props.children, childEnv);
if (children != null) insertDom(node, children);
}
const {

@@ -185,18 +156,17 @@ ref

}
throw new Error('mount: Invalid Vnode!');
}
/**
* Mount vdom as real DOM nodes.
*/
function mountDom(vnode) {
return mount(vnode);
}
/**
* Render and mount without returning VirtualDOM, useful when you don't need SVG support.
*/
function hm() {
return mountDom(h(...arguments));
function hm(...args) {
return mountDom(h(...args));
}

@@ -203,0 +173,0 @@

{
"name": "@gera2ld/jsx-dom",
"version": "2.2.1",
"version": "2.2.2",
"description": "Use JSX for HTML elements.",
"author": "Gerald <i@gerald.top>",
"license": "ISC",
"scripts": {
"prepare": "husky install",
"dev": "rollup -wc rollup.conf.js",
"build:types": "tsc -p tsconfig.prod.json",
"build:js": "rollup -c rollup.conf.js",
"build": "run-s lint test clean build:*",
"lint": "eslint --ext .ts,.tsx .",
"prepublishOnly": "run-s build",
"clean": "del-cli dist types",
"test": "cross-env BABEL_ENV=test jest test"
},
"keywords": [

@@ -39,16 +28,26 @@ "jsx",

"devDependencies": {
"@babel/plugin-transform-react-jsx": "^7.18.6",
"@gera2ld/plaid": "~2.5.5",
"@babel/plugin-transform-react-jsx": "^7.21.5",
"@gera2ld/plaid": "~2.5.6",
"@gera2ld/plaid-common-ts": "~2.5.1",
"@gera2ld/plaid-rollup": "~2.5.0",
"@gera2ld/plaid-test": "^2.5.0",
"@gera2ld/plaid-rollup": "~2.5.6",
"@gera2ld/plaid-test": "^2.5.8",
"del-cli": "^5.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.1",
"prettier": "^2.7.1"
"husky": "^8.0.3",
"jest-environment-jsdom": "^29.5.0",
"prettier": "^2.8.8"
},
"dependencies": {
"@babel/runtime": "^7.18.9"
"@babel/runtime": "^7.21.5"
},
"scripts": {
"dev": "rollup -wc rollup.conf.js",
"build:types": "tsc -p tsconfig.prod.json",
"build:js": "rollup -c rollup.conf.js",
"build": "run-s lint test clean build:*",
"lint": "eslint --ext .ts,.tsx .",
"clean": "del-cli dist types",
"test": "cross-env BABEL_ENV=test jest test"
}
}
}
export declare const VTYPE_ELEMENT = 1;
export declare const VTYPE_FUNCTION = 2;
export declare type VType = typeof VTYPE_ELEMENT | typeof VTYPE_FUNCTION;
export type VType = typeof VTYPE_ELEMENT | typeof VTYPE_FUNCTION;
export declare const SVG_NS = "http://www.w3.org/2000/svg";

@@ -5,0 +5,0 @@ export declare const NS_ATTRS: {

import { VType, VTYPE_ELEMENT, VTYPE_FUNCTION } from './consts';
export declare type VProps = {
export type VProps = {
ref?: (el: Node) => void;

@@ -14,3 +14,3 @@ innerHTML?: string;

};
export declare type VFunction = (props: VProps) => VNode;
export type VFunction = (props: VProps) => VNode;
export interface VNode {

@@ -29,8 +29,8 @@ vtype: VType;

}
export declare type VChild = string | number | boolean | null | Node | VNode;
export declare type VChildren = VChild | VChildren[];
export type VChild = string | number | boolean | null | Node | VNode;
export type VChildren = VChild | VChildren[];
export interface MountEnv {
isSvg: boolean;
}
export declare type DomNode = Node;
export declare type DomResult = DomNode | DomResult[];
export type DomNode = Node;
export type DomResult = DomNode | DomResult[];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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