hastscript
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -5,3 +5,8 @@ <!--remark setext--> | ||
1.0.1 / 2016-02-25 | ||
================== | ||
* Fix property/node detection ([`1f3b063`](https://github.com/wooorm/hastscript/commit/1f3b063)) | ||
1.0.0 / 2016-02-24 | ||
================== |
32
index.js
@@ -181,2 +181,28 @@ /** | ||
/** | ||
* Check if `value` is a valid child node of | ||
* `tagName`. | ||
* | ||
* @param {string} tagName - Parent tag-name. | ||
* @param {Object} value - Node or properties like value. | ||
* @return {boolean} - Whether `value` is a node. | ||
*/ | ||
function isNode(tagName, value) { | ||
var type = value.type; | ||
if (tagName === 'input' || !type || typeof type !== 'string') { | ||
return false; | ||
} | ||
if (typeof value.children === 'object' && 'length' in value.children) { | ||
return true; | ||
} | ||
if (tagName === 'button') { | ||
return type !== 'submit' && type !== 'reset' && type !== 'button'; | ||
} | ||
return 'value' in value; | ||
} | ||
/** | ||
* Hyperscript compatible DSL for creating virtual HAST | ||
@@ -201,7 +227,3 @@ * trees. | ||
'length' in properties || | ||
// Only allow a node at the `properties` | ||
// position when it isn’t an `input`, as those | ||
// use HTML `type` and `value` attributes too | ||
// and are void. | ||
(node.tagName !== 'input' && 'type' in properties) | ||
isNode(node.tagName, properties) | ||
) | ||
@@ -208,0 +230,0 @@ ) { |
{ | ||
"name": "hastscript", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Hyperscript compatible DSL for creating virtual HAST trees", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
11846
204