File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,28 @@ stuff.escape = function(html) {
1919 . replace ( / > / g, '>' )
2020}
2121
22+ Object . setPrototypeOf = Object . setPrototypeOf || function ( obj , proto ) {
23+ if ( ! isIE9 ( ) ) {
24+ obj . __proto__ = proto ;
25+ } else {
26+ /** IE9 fix - copy object methods from the protype to the new object **/
27+ for ( var prop in proto ) {
28+ obj [ prop ] = proto [ prop ] ;
29+ }
30+ }
31+
32+ return obj ;
33+ } ;
34+
35+ var isIE9 = function ( ) {
36+ return navigator . appVersion . indexOf ( "MSIE" ) > 0 ;
37+ } ;
38+
39+ /**
40+ * Counter for multi usage.
41+ */
42+ var counter = 0
43+
2244/**
2345 * Constructor function
2446 */
@@ -30,10 +52,10 @@ function Plugin(regexp, replacer) {
3052 self . options = options
3153 self . init ( remarkable )
3254 }
33-
55+
3456 // initialize plugin object
35- self . __proto__ = Plugin . prototype
36-
57+ Object . setPrototypeOf ( self , Plugin . prototype )
58+
3759 // clone regexp with all the flags
3860 var flags = ( regexp . global ? 'g' : '' )
3961 + ( regexp . multiline ? 'm' : '' )
@@ -43,10 +65,11 @@ function Plugin(regexp, replacer) {
4365
4466 // copy init options
4567 self . replacer = replacer
46-
68+
4769 // this plugin can be inserted multiple times,
4870 // so we're generating unique name for it
49- self . id = 'regexp-' + JSON . stringify ( Math . random ( ) ) . slice ( 2 )
71+ self . id = 'regexp-' + counter
72+ counter ++
5073
5174 return self
5275}
You can’t perform that action at this time.
0 commit comments