Comparing version 4.1.0 to 4.1.1
@@ -7,2 +7,6 @@ # Change Log | ||
## 4.1.1 - 2017-03-20 | ||
### Changed | ||
- Improved inline docs. | ||
## 4.1.0 - 2016-08-29 | ||
@@ -9,0 +13,0 @@ ### Changed |
@@ -8,22 +8,20 @@ 'use strict' | ||
// Expose module. | ||
module.exports = vdo['default'] = vdo.createElement = vdo | ||
/* | ||
* @namespace vdo | ||
* @description | ||
/** | ||
* Utility to create virtual elements. | ||
* If the given type is a string then the resulting virtual node will be created with a tagname of that string. | ||
* Otherwise if the type is a function it will be invoked, and the returned nodes used. | ||
* ```javascript | ||
* // Create a virtual element. | ||
* | ||
* @example | ||
* vdo("div", { id: "example" }, ...); // -> Node | ||
* ``` | ||
* | ||
* @param {(String|Function)} type - A nodeName or a function that returns a Node. | ||
* @param {Object} attributes - The events and attributes for the resulting element. | ||
* @param {Array} childNodes - The childNodes for the resulting element. | ||
* @param {string|Function} type - A nodeName or a function that returns a Node. | ||
* @param {object} attributes - The events and attributes for the resulting element. | ||
* @param {Node[]} childNodes - The childNodes for the resulting element. | ||
* @throws {TypeError} type must be a function or a string. | ||
* @returns {(Node|*)} | ||
* @return {Node} | ||
*/ | ||
function vdo (type, attributes /* childNodes... */) { | ||
function vdo (type, attributes /* ...childNodes: Node[] */) { | ||
attributes = attributes || {} | ||
@@ -47,28 +45,22 @@ | ||
/* | ||
* @static | ||
* @description | ||
/** | ||
* Check if an element is a virtual vdo element. | ||
* ```javascript | ||
* // Using jsx. | ||
* | ||
* @example | ||
* vdo.isElement(<body>Hello World!</body>); //-> true | ||
* ``` | ||
* | ||
* @param {*} elem - The elem to test. | ||
* @param {*} node - The node to test. | ||
* @returns {Boolean} | ||
*/ | ||
vdo.isElement = function (elem) { | ||
return Boolean(elem && elem.isVirtual) | ||
vdo.isElement = function (node) { | ||
return Boolean(node && node.isVirtual) | ||
} | ||
/* | ||
* @markSafe | ||
* @description | ||
/** | ||
* Marks a string of html as safe to be used as a child node. | ||
* ```javascript | ||
* // Using jsx. | ||
* | ||
* @example | ||
* const html = "<span></span>" | ||
* const node = <body>{vdo.markSafe(html)}</body> | ||
* String(node) //-> "<body><span></span></body>" | ||
* ``` | ||
* | ||
@@ -82,8 +74,7 @@ * @param {*} html - The html to mark as safe. | ||
/* | ||
* @static | ||
* @description | ||
/** | ||
* Utility to attach context to #createElement for sideways data loading. | ||
* The provided renderer will be immediately invoked. | ||
* ```javascript | ||
* | ||
* @example | ||
* let MyComponent = function (attributes, childNodes, context) { | ||
@@ -104,3 +95,2 @@ * return ( | ||
* html; //-> "Counter: 1" | ||
* ``` | ||
* | ||
@@ -110,5 +100,5 @@ * @param {*} context - A value that any custom render functions will be invoked with. | ||
* @throws {TypeError} The result of renderer must be a Node. | ||
* @returns {(Node)} | ||
* @returns {Node} | ||
*/ | ||
vdo['with'] = function (context, renderer) { | ||
vdo.with = function (context, renderer) { | ||
if (typeof renderer !== 'function') throw new TypeError('VDO: renderer should be a function.') | ||
@@ -115,0 +105,0 @@ |
'use strict' | ||
var escape = require('escape-html') | ||
var node = Node.prototype | ||
var CLOSED = { | ||
'area': true, | ||
'base': true, | ||
'br': true, | ||
'col': true, | ||
'command': true, | ||
'embed': true, | ||
'hr': true, | ||
'img': true, | ||
'input': true, | ||
'keygen': true, | ||
'link': true, | ||
'meta': true, | ||
'param': true, | ||
'source': true, | ||
'track': true, | ||
'wbr': true | ||
'area': 1, | ||
'base': 1, | ||
'br': 1, | ||
'col': 1, | ||
'command': 1, | ||
'embed': 1, | ||
'hr': 1, | ||
'img': 1, | ||
'input': 1, | ||
'keygen': 1, | ||
'link': 1, | ||
'meta': 1, | ||
'param': 1, | ||
'source': 1, | ||
'track': 1, | ||
'wbr': 1 | ||
} | ||
// Expose module. | ||
module.exports = Node | ||
/* | ||
/** | ||
* @private | ||
* @class Node | ||
* @description | ||
* Creates a virtual node that can be converted into html. | ||
* | ||
* @param {String} nodeName - The tagname of the element. | ||
* @param {Object} attributes - An object containing events and attributes. | ||
* @param {string} nodeName - The tagname of the element. | ||
* @param {object} attributes - An object containing events and attributes. | ||
* @param {Array} childNodes - The child nodeList for the element. | ||
@@ -45,23 +44,20 @@ */ | ||
* @constant | ||
* @description | ||
* Node type for diffing algorithms. | ||
* Regular nodes are "ELEMENT_TYPE". | ||
*/ | ||
node.nodeType = 1 | ||
Node.prototype.nodeType = 1 | ||
/* | ||
/** | ||
* @private | ||
* @constant | ||
* @description | ||
* Mark instances as VDO nodes. | ||
*/ | ||
node.isVirtual = true | ||
Node.prototype.isVirtual = true | ||
/* | ||
* @description | ||
/** | ||
* Generate valid html for the virtual node. | ||
* | ||
* @returns {String} | ||
* @returns {string} | ||
*/ | ||
node.toString = function () { | ||
Node.prototype.toString = function () { | ||
var key, attr | ||
@@ -68,0 +64,0 @@ var attributes = '' |
'use strict' | ||
var safe = Safe.prototype | ||
// Expose module. | ||
module.exports = Safe | ||
/* | ||
/** | ||
* @private | ||
* @class Safe | ||
* @description | ||
* Creates a virtual node that contains safe html. | ||
* | ||
* @param {String} html - the safe html to be used in vdo. | ||
* @param {string} html - the safe html to be used in vdo. | ||
*/ | ||
@@ -20,9 +19,8 @@ function Safe (html) { | ||
/* | ||
/** | ||
* @private | ||
* @constant | ||
* @description | ||
* Mark instances as VDO nodes. | ||
*/ | ||
safe.isVirtual = true | ||
Safe.prototype.isVirtual = true | ||
@@ -32,10 +30,8 @@ /** | ||
* @constant | ||
* @description | ||
* Node type for diffing algorithms. | ||
* Text nodes are "TEXT_TYPE". | ||
*/ | ||
safe.nodeType = 3 | ||
Safe.prototype.nodeType = 3 | ||
/* | ||
* @description | ||
/** | ||
* Return the stored safe html. | ||
@@ -45,4 +41,4 @@ * | ||
*/ | ||
safe.toString = function () { | ||
Safe.prototype.toString = function () { | ||
return this.nodeValue | ||
} |
{ | ||
"name": "vdo", | ||
"description": "Minimal JSX compatible html focused templating engine.", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"author": "Dylan Piercey <pierceydylan@gmail.com>", | ||
@@ -14,3 +14,3 @@ "bugs": "https://github.com/DylanPiercey/vdo/issues", | ||
"snazzy": "^6.0.0", | ||
"standard": "^8.6.0" | ||
"standard": "^9.0.2" | ||
}, | ||
@@ -17,0 +17,0 @@ "homepage": "https://github.com/DylanPiercey/vdo", |
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
9880
211