mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 08:51:22 +00:00
Make sure fixed preventDefault can be called multiple times
Fixes #441 Interact .draggable and webcomponentsjs conflict in IE
This commit is contained in:
@@ -534,12 +534,17 @@
|
||||
Event.prototype.preventDefault = function() {
|
||||
if (!this.cancelable)
|
||||
return;
|
||||
|
||||
unsafeUnwrap(this).preventDefault();
|
||||
Object.defineProperty(this, 'defaultPrevented', {
|
||||
get: function() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!this.defaultPrevented) {
|
||||
Object.defineProperty(this, 'defaultPrevented', {
|
||||
get: function() {
|
||||
return true;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
if (!window.performance) {
|
||||
var start = Date.now();
|
||||
// only at millisecond precision
|
||||
window.performance = {now: function(){ return Date.now() - start }};
|
||||
window.performance = {now: function(){ return Date.now() - start; }};
|
||||
}
|
||||
|
||||
// polyfill for requestAnimationFrame
|
||||
@@ -64,12 +64,17 @@
|
||||
if (!this.cancelable) {
|
||||
return;
|
||||
}
|
||||
|
||||
origPreventDefault.call(this);
|
||||
Object.defineProperty(this, 'defaultPrevented', {
|
||||
get: function() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!this.defaultPrevented) {
|
||||
Object.defineProperty(this, 'defaultPrevented', {
|
||||
get: function() {
|
||||
return true;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@
|
||||
var e = new Event('foo', {cancelable: true});
|
||||
e.preventDefault();
|
||||
assert.isTrue(e.defaultPrevented);
|
||||
// call again, just in case
|
||||
assert.doesNotThrow(e.preventDefault);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user