Fixed remarkable-regex not support IE, and use counter instead of random on id to avoid collision
This commit is contained in:
parent
db324c5624
commit
ddd1740f71
1 changed files with 28 additions and 5 deletions
27
public/vendor/remarkable-regex.js
vendored
27
public/vendor/remarkable-regex.js
vendored
|
@ -19,6 +19,28 @@ stuff.escape = function(html) {
|
||||||
.replace(/>/g, '>')
|
.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
|
* Constructor function
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +54,7 @@ function Plugin(regexp, replacer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize plugin object
|
// initialize plugin object
|
||||||
self.__proto__ = Plugin.prototype
|
Object.setPrototypeOf(self, Plugin.prototype)
|
||||||
|
|
||||||
// clone regexp with all the flags
|
// clone regexp with all the flags
|
||||||
var flags = (regexp.global ? 'g' : '')
|
var flags = (regexp.global ? 'g' : '')
|
||||||
|
@ -46,7 +68,8 @@ function Plugin(regexp, replacer) {
|
||||||
|
|
||||||
// this plugin can be inserted multiple times,
|
// this plugin can be inserted multiple times,
|
||||||
// so we're generating unique name for it
|
// so we're generating unique name for it
|
||||||
self.id = 'regexp-' + JSON.stringify(Math.random()).slice(2)
|
self.id = 'regexp-' + counter
|
||||||
|
counter++
|
||||||
|
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue