Skip to content

Commit

Permalink
Fix attribute encoding issues
Browse files Browse the repository at this point in the history
  • Loading branch information
developit committed Dec 21, 2015
1 parent bd43a74 commit f188259
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const EMPTY = {};

const HOP = Object.prototype.hasOwnProperty;

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

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

// #text nodes
if (!nodeName) {
return escape(vnode);
return encodeEntities(vnode);
}

// components
Expand Down Expand Up @@ -70,8 +70,8 @@ function internalRender(vnode, opts, root) {
if (attributes['class']) continue;
name = 'class';
}
if (v!==null && v!==undefined) {
s += ` ${name}="${escape(v)}"`;
if (v!==null && v!==undefined && typeof v!=='function') {
s += ` ${name}="${encodeEntities(String(v))}"`;
}
}
}
Expand Down

0 comments on commit f188259

Please sign in to comment.