Skip to content

Commit f188259

Browse files
committed
Fix attribute encoding issues
1 parent bd43a74 commit f188259

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const EMPTY = {};
1111

1212
const HOP = Object.prototype.hasOwnProperty;
1313

14-
let escape = s => String(s).replace(/[<>"&]/, a => ESC[a] || a);
14+
let encodeEntities = s => String(s).replace(/[<>"&]/g, a => ESC[a] || a);
1515

1616
/** Convert JSX to a string, rendering out all nested components along the way.
1717
* @param {VNode} vnode A VNode, generally created via JSX
@@ -34,7 +34,7 @@ function internalRender(vnode, opts, root) {
3434

3535
// #text nodes
3636
if (!nodeName) {
37-
return escape(vnode);
37+
return encodeEntities(vnode);
3838
}
3939

4040
// components
@@ -70,8 +70,8 @@ function internalRender(vnode, opts, root) {
7070
if (attributes['class']) continue;
7171
name = 'class';
7272
}
73-
if (v!==null && v!==undefined) {
74-
s += ` ${name}="${escape(v)}"`;
73+
if (v!==null && v!==undefined && typeof v!=='function') {
74+
s += ` ${name}="${encodeEntities(String(v))}"`;
7575
}
7676
}
7777
}

0 commit comments

Comments
 (0)