on master help sign in
Fix display bug in `toText` function. Strings were not escaped properly :/ Now they are!
commitb9380718ce3f1f86bdbba5be5253f242929e07e3 authorevancz <info@elm-lang.org> dateTue 14 Aug 2012, 14:10 (14 years ago) parentcb9d296
2 files changed+10−9
core-js/Value.js+8−7 core-js/foreign/JSON.js+2−2
core-js/Value.js+8−7
@@ -33,12 +33,13 @@ var Value = function(){
3333 };
3434
3535 var properEscape = function(str) {
36− str.replace('"', "&#34;");
37− str.replace("&", "&#38;");
38− str.replace("'", "&#39;");
39− str.replace("<", "&#60;");
40− str.replace(">", "&#62;");
41− return str;
36+ return str.replace(/&/g, "&#38;")
37+ .replace(/"/g, /*"*/ "&#34;")
38+ .replace(/'/g, /*'*/ "&#39;")
39+ .replace(/</g, "&#60;")
40+ .replace(/>/g, "&#62;")
41+ .replace(/ /g, "&nbsp;")
42+ .replace(/\n/g, "<br/>");
4243 };
4344
4445 var toText = function(elmList) {
@@ -56,7 +57,7 @@ var Value = function(){
5657 return v ? "True" : "False";
5758 } else if (typeof v === "number") {
5859 return v+"";
59− } else if (typeof v === "string") {
60+ } else if (typeof v === "string" && v.length < 2) {
6061 return "'"+v+"'";
6162 } else if (v[0]) {
6263 if (v[0].substring(0,5) === "Tuple") {
core-js/foreign/JSON.js+2−2
@@ -87,7 +87,7 @@ var ElmJSON = function() {
8787 return v[1];
8888 }
8989 }
90− return JSON.stringify(fromValue([ 'JsonObject', obj ]), null, JS.castStringToJSString(sep));
90+ return Value.toText(JSON.stringify(fromValue([ 'JsonObject', obj ]), null, JS.castStringToJSString(sep)));
9191 };
9292 }
9393 function fromJSString(str) {
@@ -115,7 +115,7 @@ var ElmJSON = function() {
115115 singleton : singleton,
116116 insert : insert,
117117 lookup : lookup,
118− lookupWithDefault : lookupWithDefault,
118+ findWithDefault : lookupWithDefault,
119119 remove : remove,
120120 toPrettyJSString : toPrettyJSString,
121121 toJSString : toPrettyJSString(''),