fix stopPropagation override for IE11#2390
Conversation
|
Size Change: +53 B (0%) Total Size: 38.5 kB
ℹ️ View Unchanged
|
|
I may be misunderstanding . <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Test</title>
</head>
<body>
<div id="bar">
<div id="foo">foo<br>foo<br>foo<br></div>
</div>
<script type="text/javascript">
var foo = document.getElementById('foo')
foo.addEventListener('click', function(e) {
var stopPropagation = e.stopPropagation
e.stopPropagation = function() {stopPropagation.call(this)};
e.stopPropagation();
console.log('Foo');
}, false);
var bar = document.getElementById('bar')
bar.addEventListener('click', function(e) {
console.log('Bar');
}, false);
</script>
</body>
</html> |
|
@38elements look at the IE11 tests on master, or something weird happens to the closure on IE11 or the override doesn't take effect. These tests only run on master, https://travis-ci.org/preactjs/preact/builds/656971648?utm_source=github_status&utm_medium=notification We can enable them by enabling |
|
@JoviDeCroock preact/compat/test/browser/events.test.js Line 51 in 0aaa855 But, this code worked normally in IE11. <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Test</title>
</head>
<body>
<div id="foo">foo<br>foo<br>foo<br></div>
<script type="text/javascript">
var foo = document.getElementById('foo')
foo.addEventListener('click', function(e) {
console.log(e.defaultPrevented)
e.preventDefault()
console.log(e.defaultPrevented)
console.log('Foo');
}, false);
</script>
</body>
</html>import { createElement as h, render, Component } from 'preact/compat'
function App() {
function onClick(event) {
console.log('isDefaultPrevented=' + event.isDefaultPrevented())
event.preventDefault()
console.log('isDefaultPrevented=' + event.isDefaultPrevented())
console.log('isPropagationStopped=' + event.isPropagationStopped())
event.stopPropagation()
console.log('isPropagationStopped=' + event.isPropagationStopped())
}
return <div onClick={onClick}>foo<br/>foo<br/>foo</div>
}
render(<App />, document.body) |
|
Seems like IE11 on Windows 7 was indeed bugging out, thanks @38elements I must've missed the line-number. You're a hero! |
95a9a35 to
9805969
Compare
9805969 to
2976865
Compare

IE11 throws an error when overriding the stopPropagation method on an event