@elliottsj/react-render-html
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -65,4 +65,4 @@ 'use strict'; | ||
function applyMiddleware() { | ||
for (var _len2 = arguments.length, transformers = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
transformers[_key2] = arguments[_key2]; | ||
for (var _len2 = arguments.length, middlewares = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
middlewares[_key2] = arguments[_key2]; | ||
} | ||
@@ -72,4 +72,4 @@ | ||
return function (node, key) { | ||
var chain = transformers.map(function (transformer) { | ||
return transformer(renderNode); | ||
var chain = middlewares.map(function (middleware) { | ||
return middleware(renderNode); | ||
}); | ||
@@ -82,3 +82,3 @@ return compose.apply(undefined, _toConsumableArray(chain))(node, key); | ||
function renderHTML(html) { | ||
var renderNode = arguments.length <= 1 || arguments[1] === undefined ? function () { | ||
var middleware = arguments.length <= 1 || arguments[1] === undefined ? function () { | ||
return function (next) { | ||
@@ -98,3 +98,3 @@ return function () { | ||
var finalRenderNode = function finalRenderNode(node, key) { | ||
return renderNode(finalRenderNode)(baseRenderNode(finalRenderNode))(node, key); | ||
return middleware(finalRenderNode)(baseRenderNode(finalRenderNode))(node, key); | ||
}; | ||
@@ -101,0 +101,0 @@ var result = htmlAST.childNodes.map(finalRenderNode); |
{ | ||
"name": "@elliottsj/react-render-html", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "No more dangerouslySetInnerHTML, render HTML as React element.", | ||
@@ -8,3 +8,3 @@ "main": "lib/index.js", | ||
"build": "babel src --out-dir lib", | ||
"develop": "babel src --watch --out-dir lib", | ||
"build:watch": "babel src --watch --out-dir lib", | ||
"lint": "xo src/**", | ||
@@ -11,0 +11,0 @@ "prepublish": "npm run build", |
@@ -30,5 +30,5 @@ import parse5 from 'parse5'; | ||
export function applyMiddleware(...transformers) { | ||
export function applyMiddleware(...middlewares) { | ||
return renderNode => (node, key) => { | ||
const chain = transformers.map(transformer => transformer(renderNode)); | ||
const chain = middlewares.map(middleware => middleware(renderNode)); | ||
return compose(...chain)(node, key); | ||
@@ -38,3 +38,3 @@ }; | ||
export default function renderHTML(html, renderNode = () => next => (...args) => next(...args)) { | ||
export default function renderHTML(html, middleware = () => next => (...args) => next(...args)) { | ||
const htmlAST = parse5.parseFragment(html); | ||
@@ -47,3 +47,3 @@ | ||
const finalRenderNode = | ||
(node, key) => renderNode(finalRenderNode)(baseRenderNode(finalRenderNode))(node, key); | ||
(node, key) => middleware(finalRenderNode)(baseRenderNode(finalRenderNode))(node, key); | ||
const result = htmlAST.childNodes.map(finalRenderNode); | ||
@@ -50,0 +50,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
14860