From 150f0360d41c4d80a4cbaaf80dc9a13232a1e5d8 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 5 Nov 2013 20:37:48 +0400 Subject: [PATCH] fix #1624 Rules added with embedRules can only use stringed regexes --- lib/ace/lib/lang.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/ace/lib/lang.js b/lib/ace/lib/lang.js index 4e6ebf2c..0a0690e8 100644 --- a/lib/ace/lib/lang.js +++ b/lib/ace/lib/lang.js @@ -78,14 +78,16 @@ exports.copyArray = function(array){ }; exports.deepCopy = function (obj) { - if (typeof obj != "object") { + if (typeof obj !== "object" || !obj) + return obj; + var cons = obj.constructor; + if (cons === RegExp) return obj; - } - var copy = obj.constructor(); + var copy = cons(); for (var key in obj) { - if (typeof obj[key] == "object") { - copy[key] = this.deepCopy(obj[key]); + if (typeof obj[key] === "object") { + copy[key] = exports.deepCopy(obj[key]); } else { copy[key] = obj[key]; }