commit c87b20aadde0318b5c221deb8741c8ed4dd90fff
parent 1f90b365180d74bf30d49815f2b78b01b81522c6
Author: Emily Eisenberg <xymostech@gmail.com>
Date: Fri, 1 May 2015 11:43:09 -0700
Merge pull request #225 from jeresig/clone-buildhtml
buildHTML's buildExpression is destructive, changing the tree object.
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/buildHTML.js b/src/buildHTML.js
@@ -1157,6 +1157,10 @@ var buildGroup = function(group, options, prev) {
* nodes.
*/
var buildHTML = function(tree, settings) {
+ // buildExpression is destructive, so we need to make a clone
+ // of the incoming tree so that it isn't accidentally changed
+ tree = JSON.parse(JSON.stringify(tree));
+
var startStyle = Style.TEXT;
if (settings.displayMode) {
startStyle = Style.DISPLAY;