Here was my code fragment with the addition of the global method gsa ( G et / S et A ttribute):
Object.prototype.gsa = function (){ if (arguments.length == 1) return this.getAttribute(arguments[0]); this.setAttribute(arguments[0],arguments[1]); } When the big project was completed, I decided to run it through all browsers ( on the local server ). Wow, the code works in all applications. However, the Opera suddenly showed unexpected results. Yes, the application on js is completely working, nothing to complain about, but if you open the developer console, you can see how an exception is thrown:
Uncaught TypeError: Cannot read property 'setAttribute' of undefined at Object.gsa (config.js:12) at t (ldr_656_11438_wFkRME.js:1) at XX (ldr_656_11438_wFkRME.js:1) at X.serialize (ldr_656_11438_wFkRME.js:1) at X.ajax (ldr_656_11438_wFkRME.js:1) at Object.req (ldr_656_11438_wFkRME.js:1) at Storage.Đ’ (ldr_656_11438_wFkRME.js:1) at new Storage (ldr_656_11438_wFkRME.js:1) at ldr_656_11438_wFkRME.js:1 at ldr_656_11438_wFkRME.js:2 Interested in the first file in the list - config.js - this is my configuration file from the project and connects first. (The remaining files are not mine - they probably work in the depths of the Opera).
After 3 hours of searching for the mysterious appeal of an unknown object to the gsa method, I completely isolated this fragment from the rest of the code. Therefore, there are no js-file connections, no objects are created, and there are no calls to the gsa method. Simply put, the entire js-code has become only this fragment. But Opera still continues to throw an exception. Of course, I was upset and in the first line of the function I wrote:
if (!this) return; The code began to work properly. Questions: why in the browser Opera there is such an error? Which object without its context this secretly refers to the gsa method? Why don't other browsers behave in this way?
UPDATE. All browsers are updated to the latest version.