8
I’m using Shim that modifies several of the properties in the window object of browsers.
At this point I need to validate whether one of the specified properties is native or a Shim. Because Shim can modify the native property.
For example:
(function () {
var native = window.alert;
window.alert = function (): {
/* faz alguma coisa */
console.log(arguments);
return native.apply(this, arguments);
};
})();
In the example we can see that it does not change the functionality of alert
applying the original at the end, but this alert
is no longer the original in another code snippet I would like to know if this method is the original or a modified.
The alert
was used only as example purposes of the problem.
Without modifying the "Shim" that no longer exposes the alert
native, how to access the alert
native to compare with the modified and know that the function in the window
is not the native?
If not implemented, it returns false when using in an if().
– 2madera
@2madera that’s not what I asked,
alert
will return true if it is modified or native. I want to know if it is native or not. If it exists in the objectwindow
is another very simple thing to solve.– Gabriel Gartz