hastscript
Advanced tools
Comparing version 3.0.1 to 3.1.0
28
index.js
@@ -1,13 +0,3 @@ | ||
/** | ||
* @author Titus Wormer | ||
* @copyright 2016 Titus Wormer | ||
* @license MIT | ||
* @module hastscript | ||
* @fileoverview Hyperscript compatible DSL for creating | ||
* virtual HAST trees. | ||
*/ | ||
'use strict'; | ||
/* Dependencies. */ | ||
var parseSelector = require('hast-util-parse-selector'); | ||
@@ -19,15 +9,6 @@ var camelcase = require('camelcase'); | ||
/* Expose. */ | ||
module.exports = h; | ||
/** | ||
* Hyperscript compatible DSL for creating virtual HAST | ||
* trees. | ||
* | ||
* @param {string?} selector - Simple CSS selector to parse. | ||
* @param {Object?} properties - HTML attributes to add. | ||
* @param {string|Array.<string|Node>} children - List of | ||
* children to add. | ||
* @return {Node} - HAST node. | ||
*/ | ||
/* Hyperscript compatible DSL for creating virtual HAST | ||
* trees. */ | ||
function h(selector, properties, children) { | ||
@@ -58,2 +39,7 @@ var node = parseSelector(selector); | ||
if (node.tagName === 'template') { | ||
node.content = {type: 'root', children: node.children}; | ||
node.children = []; | ||
} | ||
return node; | ||
@@ -60,0 +46,0 @@ } |
{ | ||
"name": "hastscript", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Hyperscript compatible DSL for creating virtual HAST trees", | ||
@@ -16,4 +16,4 @@ "license": "MIT", | ||
], | ||
"repository": "https://github.com/wooorm/hastscript", | ||
"bugs": "https://github.com/wooorm/hastscript/issues", | ||
"repository": "https://github.com/syntax-tree/hastscript", | ||
"bugs": "https://github.com/syntax-tree/hastscript/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
@@ -34,12 +34,12 @@ "contributors": [ | ||
"devDependencies": { | ||
"browserify": "^13.0.0", | ||
"browserify": "^14.3.0", | ||
"esmangle": "^1.0.0", | ||
"nyc": "^8.1.0", | ||
"remark-cli": "^2.0.0", | ||
"remark-preset-wooorm": "^1.0.0", | ||
"nyc": "^11.0.0", | ||
"remark-cli": "^4.0.0", | ||
"remark-preset-wooorm": "^3.0.0", | ||
"tape": "^4.0.0", | ||
"xo": "^0.16.0" | ||
"xo": "^0.18.0" | ||
}, | ||
"scripts": { | ||
"build-md": "remark . --quiet --frail", | ||
"build-md": "remark . -qfo", | ||
"build-bundle": "browserify index.js --bare -s hastscript > hastscript.js", | ||
@@ -61,6 +61,6 @@ "build-mangle": "esmangle hastscript.js > hastscript.min.js", | ||
"space": true, | ||
"esnext": false, | ||
"rules": { | ||
"no-self-compare": "off", | ||
"guard-for-in": "off", | ||
"max-lines": "off" | ||
"guard-for-in": "off" | ||
}, | ||
@@ -72,5 +72,6 @@ "ignores": [ | ||
"remarkConfig": { | ||
"output": true, | ||
"presets": "wooorm" | ||
"plugins": [ | ||
"preset-wooorm" | ||
] | ||
} | ||
} |
@@ -16,21 +16,12 @@ # hastscript [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
Dependencies: | ||
```javascript | ||
var h = require('hastscript'); | ||
``` | ||
AST: | ||
```javascript | ||
var tree = h('.foo#some-id', [ | ||
h('span', 'some text'), | ||
h('input', { | ||
'type': 'text', | ||
'value': 'foo' | ||
}), | ||
h('a.alpha', { | ||
'class': 'bravo charlie', | ||
'download': 'download' | ||
}, ['delta', 'echo']) | ||
h('span', 'some text'), | ||
h('input', {type: 'text', value: 'foo'}), | ||
h('a.alpha', { | ||
class: 'bravo charlie', | ||
download: 'download' | ||
}, ['delta', 'echo']) | ||
]); | ||
@@ -68,18 +59,22 @@ ``` | ||
###### Parameters | ||
##### Parameters | ||
* `selector` (`string`, optional) | ||
— Simple CSS selector, e.g., tag names (`foo`), IDs (`#bar`) | ||
and classes (`.baz`) are supported, | ||
defaults to a `div` element. | ||
* `properties` (`Object.<string, *>`, optional) | ||
— Map of properties; | ||
* `children` (`string`, `Node`, `Array.<string|Node>`, optional) | ||
— (List of) child nodes, when strings are encountered, | ||
they are normalised to [`text`][text] nodes. | ||
###### `selector` | ||
###### Returns | ||
Simple CSS selector (`string`, optional). Can contain a tag name (`foo`), IDs | ||
(`#bar`), and classes (`.baz`), defaults to a `div` element. | ||
[`Node`][hast-node] — A HAST node. | ||
###### `properties` | ||
Map of properties (`Object.<string, *>`, optional). | ||
###### `children` | ||
(List of) child nodes (`string`, `Node`, `Array.<string|Node>`, optional). | ||
When strings are encountered, they are normalised to [`text`][text] nodes. | ||
##### Returns | ||
[`Element`][element]. | ||
## License | ||
@@ -91,9 +86,9 @@ | ||
[travis-badge]: https://img.shields.io/travis/wooorm/hastscript.svg | ||
[travis-badge]: https://img.shields.io/travis/syntax-tree/hastscript.svg | ||
[travis]: https://travis-ci.org/wooorm/hastscript | ||
[travis]: https://travis-ci.org/syntax-tree/hastscript | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/hastscript.svg | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/syntax-tree/hastscript.svg | ||
[codecov]: https://codecov.io/github/wooorm/hastscript | ||
[codecov]: https://codecov.io/github/syntax-tree/hastscript | ||
@@ -106,5 +101,5 @@ [npm]: https://docs.npmjs.com/cli/install | ||
[hast]: https://github.com/wooorm/hast | ||
[hast]: https://github.com/syntax-tree/hast | ||
[hast-node]: https://github.com/wooorm/hast#node | ||
[element]: https://github.com/syntax-tree/hast#element | ||
@@ -115,2 +110,2 @@ [virtual-hyperscript]: https://github.com/Matt-Esch/virtual-dom/tree/master/virtual-hyperscript | ||
[text]: https://github.com/wooorm/hast#text | ||
[text]: https://github.com/syntax-tree/unist#text |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
9603
4
0
144
107