hastscript
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -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 @@ |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12139
173
0
164