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

snabbdom-jsx-lite

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snabbdom-jsx-lite - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

9

package.json
{
"name": "snabbdom-jsx-lite",
"version": "1.0.3",
"version": "1.0.4",
"description": "Write snabbdom templates in .jsx or .tsx (JSX for TypeScript)",

@@ -39,3 +39,3 @@ "files": [

"eslint-plugin-react": "7.18.3",
"lint-config-nojvek": "1.0.2",
"lint-config-nojvek": "1.0.3",
"prettier": "2.0.5",

@@ -50,3 +50,6 @@ "prettier-eslint": "9.0.1",

},
"dependencies": {}
"dependencies": {},
"peerDependencies": {
"snabbdom": ">=0.6.1"
}
}

@@ -40,2 +40,3 @@ # snabbdom-jsx-lite

<div>
{/* `sel` is css selector shorthand, <img sel=".profile" /> is same as <img class={profile: true} /> */}
<img sel=".profile" attrs={{src: 'avatar.png'}} />

@@ -42,0 +43,0 @@ <h3>{[user.firstName, user.lastName].join(' ')}</h3>

@@ -7,3 +7,6 @@ import {vnode, VNode, VNodeData} from 'snabbdom/vnode';

export type JsxVNodeChildren = JsxVNodeChild | JsxVNodeChild[];
export type JsxVNodeProps = VNodeData & {sel?: string};
export interface JsxVNodeProps extends VNodeData {
/** css selector shorthand e.g <div sel="#id.class1.class1" /> */
sel?: string;
}

@@ -69,3 +72,3 @@ export type FunctionComponent = (props: {[prop: string]: any} | null, children?: VNode[]) => VNode;

// append sel css selector to tag to support equivalent of h('span.foo.bar')
// append sel css selector to tag to support equivalent of h('div.foo.bar')
if (data && data.sel) {

@@ -76,5 +79,6 @@ tag += data.sel;

// NOTE: we don't hook into snabbdom's h, but directly create vnodes.
// h is just a similar wrapper for creating vnodes. This lets us be performant
if (flattenedChildren.length === 1 && flattenedChildren[0].sel === undefined && flattenedChildren[0].text) {
const numFlattenedChildren = flattenedChildren.length;
if (numFlattenedChildren === 0) {
return vnode(tag, data, undefined, undefined, undefined);
} else if (numFlattenedChildren === 1 && flattenedChildren[0].sel === undefined && flattenedChildren[0].text) {
// only child is a simple text node, return as simple text node

@@ -81,0 +85,0 @@ return vnode(tag, data, undefined, flattenedChildren[0].text, undefined);

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