Let's say I call window.alert('my message')
in dart code. But what if (exactly my case) there is a script which did override alert
function before my script. Now if I try to call window.alert('message')
It executes overridden alert
function instead of initial one.
Is there a mechanism to ensure that all functions are not overridden in described way? Or should I always make sure that dart script is the first to execute on page to ensure that no undesirable overrides are done and behavior is stable and it's the only way to go?
Here is basic github repo if you would like to see the issue live.
EDIT 1:
main.dart
import 'dart:html';
void main() {
window.alert('alert');
}
index.html
<html>
<head>
<title>test</title>
<script>
alert = (variable) => confirm("hehe it's jinxed");
</script>
<script defer src="main.dart.js"></script>
</head>
</html>