File tree 1 file changed +7
-2
lines changed 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -99,9 +99,14 @@ exports.escapeXML = function (markup) {
99
99
: String ( markup )
100
100
. replace ( _MATCH_HTML , encode_char ) ;
101
101
} ;
102
- exports . escapeXML . toString = function ( ) {
102
+
103
+ // If the Object prototype is frozen, the "toString" property is non-writable. This means that any objects which inherit this property
104
+ // cannot have the property changed using an assignment. If using strict mode, attempting that will cause an error. If not using strict
105
+ // mode, attempting that will be silently ignored.
106
+ // However, we can still explicitly shadow the prototype's "toString" property by defining a new "toString" property on this object.
107
+ Object . defineProperty ( exports . escapeXML , 'toString' , function ( ) {
103
108
return Function . prototype . toString . call ( this ) + ';\n' + escapeFuncStr ;
104
- } ;
109
+ } ) ;
105
110
106
111
/**
107
112
* Naive copy of properties from one object to another.
You can’t perform that action at this time.
0 commit comments