Inside jQuery, new Date()
is giving out the error "This is an unsupported operation for this object".
I'd like to know how to avoid this.
I don't know the reproduction conditions and I can't provide a minimum reproduction source, so let me explain the situation instead.
Also, the environment where the reproduction was confirmed is IE11 and Edge.It does not occur in Chrome.
Below is the IE11 Developer Tool (F12).
The source you see is from jQuery 1.11.3.
The following image shows the call stack when the above error occurred.
The eighth request.js
from the top is the code I wrote.
Calling jQuery's ajax
method
The following image shows the global variable Date
from the variable watch when the debugger stops when an error occurs.
For some reason it is undefined
.
I don't know the root cause of the error, but this seems to be the direct cause.
The following image just checked to see if the jQuery
variable exists as above.
jQuery
was found, but for some reason $
is undefined
.
The following image shows IE crashing while checking on the watch above.
When I added jQuery
to the watch list again, it crashed.
After several attempts, the crash timing may vary slightly, but it can be reproduced by adding jQuery
to the watch more than once.
add
The code for the problem above always occurs.
If you put a breakpoint on the send part of the sixth line above the call stack, next to Asynchronous Calls, and stop it, the Date is present at that time.
Also, just as Date was undefined, String and Number were undefined.
It's hard to lose your browser while debugging.
For example, how about stocking it in the global namespace at the beginning of the program to monitor and reject changes to Date
(also $
if necessary)?
// Reject Date Changes
constorig_date = Date;
Object.defineProperty(
This, "Date", {
set:function(v){
console.log("!NOT ALLOWED:set Date:",v);
console.trace();
},
get: function() {return origin_date;},
}
);
© 2024 OneMinuteCode. All rights reserved.