summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWu Cheng-Han2016-01-12 07:34:44 -0600
committerWu Cheng-Han2016-01-12 07:34:44 -0600
commitddd1740f7132c2f95644926468c7be005e887a91 (patch)
treed4195f36b8168d95195ab675f0b642d6065c1b8b
parentdb324c562493c92b9fe3eeb03f27737a3d1e303d (diff)
Fixed remarkable-regex not support IE, and use counter instead of random on id to avoid collision
-rw-r--r--public/vendor/remarkable-regex.js33
1 files changed, 28 insertions, 5 deletions
diff --git a/public/vendor/remarkable-regex.js b/public/vendor/remarkable-regex.js
index b8b829ef..f7545140 100644
--- a/public/vendor/remarkable-regex.js
+++ b/public/vendor/remarkable-regex.js
@@ -19,6 +19,28 @@ stuff.escape = function(html) {
.replace(/>/g, '>')
}
+Object.setPrototypeOf = Object.setPrototypeOf || function (obj, proto) {
+ if (!isIE9()) {
+ obj.__proto__ = proto;
+ } else {
+ /** IE9 fix - copy object methods from the protype to the new object **/
+ for (var prop in proto) {
+ obj[prop] = proto[prop];
+ }
+ }
+
+ return obj;
+};
+
+var isIE9 = function() {
+ return navigator.appVersion.indexOf("MSIE") > 0;
+};
+
+/**
+ * Counter for multi usage.
+ */
+var counter = 0
+
/**
* Constructor function
*/
@@ -30,10 +52,10 @@ function Plugin(regexp, replacer) {
self.options = options
self.init(remarkable)
}
-
+
// initialize plugin object
- self.__proto__ = Plugin.prototype
-
+ Object.setPrototypeOf(self, Plugin.prototype)
+
// clone regexp with all the flags
var flags = (regexp.global ? 'g' : '')
+ (regexp.multiline ? 'm' : '')
@@ -43,10 +65,11 @@ function Plugin(regexp, replacer) {
// copy init options
self.replacer = replacer
-
+
// this plugin can be inserted multiple times,
// so we're generating unique name for it
- self.id = 'regexp-' + JSON.stringify(Math.random()).slice(2)
+ self.id = 'regexp-' + counter
+ counter++
return self
}