preact-render-to-string
Advanced tools
Comparing version 3.0.4 to 3.0.5
@@ -161,3 +161,3 @@ (function (global, factory) { | ||
var hooked = opts.attributeHook && opts.attributeHook(name, v, context, opts); | ||
if (hooked) { | ||
if (hooked || hooked === '') { | ||
s += hooked; | ||
@@ -164,0 +164,0 @@ continue; |
@@ -173,3 +173,3 @@ (function (global, factory) { | ||
var hooked = opts.attributeHook && opts.attributeHook(name, v, context, opts); | ||
if (hooked) { | ||
if (hooked || hooked === '') { | ||
s += hooked; | ||
@@ -631,2 +631,4 @@ continue; | ||
function attributeHook(name, value, context, opts) { | ||
if (value == null) return ''; | ||
var indentChar = typeof opts.pretty === 'string' ? opts.pretty : '\t'; | ||
@@ -633,0 +635,0 @@ if (typeof value !== 'string') { |
{ | ||
"name": "preact-render-to-string", | ||
"amdName": "preactRenderToString", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Render JSX to an HTML string, with support for Preact components.", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
@@ -111,3 +111,3 @@ import { objectKeys, encodeEntities, falsey, memoize, indent, isLargeString, styleObjToCss, assign, getNodeProps } from './util'; | ||
let hooked = opts.attributeHook && opts.attributeHook(name, v, context, opts); | ||
if (hooked) { | ||
if (hooked || hooked==='') { | ||
s += hooked; | ||
@@ -114,0 +114,0 @@ continue; |
@@ -24,2 +24,4 @@ import './polyfills'; | ||
function attributeHook(name, value, context, opts) { | ||
if (value==null) return ''; | ||
let indentChar = typeof opts.pretty==='string' ? opts.pretty : '\t'; | ||
@@ -26,0 +28,0 @@ if (typeof value!=='string') { |
@@ -73,2 +73,12 @@ import render from '../src/jsx'; | ||
it('should skip null and undefined attributes', () => { | ||
expect(renderJsx( | ||
<a b={null}>bar</a> | ||
)).to.equal(`<a>bar</a>`); | ||
expect(renderJsx( | ||
<a b={undefined}>bar</a> | ||
)).to.equal(`<a>bar</a>`); | ||
}); | ||
it('should render attributes containing VNodes', () => { | ||
@@ -75,0 +85,0 @@ expect(renderJsx( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
117172
1609