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

hastscript

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hastscript - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

11

factory.js

@@ -15,8 +15,9 @@ 'use strict'

/* Hyperscript compatible DSL for creating virtual HAST trees. */
function h(selector, properties, children) {
function h(selector, properties) {
var node = parseSelector(selector, defaultTagName)
var children = Array.prototype.slice.call(arguments, 2)
var property
if (!children && properties && isChildren(properties, node)) {
children = properties
if (properties && isChildren(properties, node)) {
children.unshift(properties)
properties = null

@@ -117,6 +118,2 @@ }

if (value === null || value === undefined) {
return
}
if (typeof value === 'string' || typeof value === 'number') {

@@ -123,0 +120,0 @@ nodes.push({type: 'text', value: String(value)})

{
"name": "hastscript",
"version": "4.0.0",
"version": "4.1.0",
"description": "Hyperscript compatible DSL for creating virtual HAST trees",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -20,2 +20,3 @@ # hastscript [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]

// Child nodes as an array
console.log(

@@ -32,3 +33,14 @@ h('.foo#some-id', [

// Child nodes as arguments
console.log(
h(
'form',
{method: 'POST'},
h('input', {type: 'text', name: 'foo'}),
h('input', {type: 'text', name: 'bar'}),
h('input', {type: 'submit', value: 'send'})
)
)
console.log(
s('svg', {xmlns: 'http://www.w3.org/2000/svg', viewbox: '0 0 500 500'}, [

@@ -63,2 +75,18 @@ s('title', 'SVG `<circle>` element'),

{ type: 'element',
tagName: 'form',
properties: { method: 'POST' },
children:
[ { type: 'element',
tagName: 'input',
properties: { type: 'text', name: 'foo' },
children: [] },
{ type: 'element',
tagName: 'input',
properties: { type: 'text', name: 'bar' },
children: [] },
{ type: 'element',
tagName: 'input',
properties: { type: 'submit', value: 'send' },
children: [] } ] }
{ type: 'element',
tagName: 'svg',

@@ -79,5 +107,5 @@ properties: { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 500 500' },

### `h(selector?[, properties][, children])`
### `h(selector?[, properties][, ...children])`
### `s(selector?[, properties][, children])`
### `s(selector?[, properties][, ...children])`

@@ -101,3 +129,3 @@ DSL to create virtual [HAST][] trees for HTML or SVG.

(List of) child nodes (`string`, `Node`, `Array.<string|Node>`, optional).
(Lists of) child nodes (`string`, `Node`, `Array.<string|Node>`, optional).
When strings are encountered, they are normalised to [`text`][text] nodes.

@@ -104,0 +132,0 @@

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