mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
disallow passive|preventDefault combo
This commit is contained in:
parent
82b1b75afe
commit
b3b95d4ee6
@ -585,6 +585,13 @@ export default class Element extends Node {
|
||||
]);
|
||||
|
||||
this.handlers.forEach(handler => {
|
||||
if (handler.modifiers.has('passive') && handler.modifiers.has('preventDefault')) {
|
||||
component.error(handler, {
|
||||
code: 'invalid-event-modifier',
|
||||
message: `The 'passive' and 'preventDefault' modifiers cannot be used together`
|
||||
});
|
||||
}
|
||||
|
||||
handler.modifiers.forEach(modifier => {
|
||||
if (!validModifiers.has(modifier)) {
|
||||
component.error(handler, {
|
||||
@ -619,7 +626,7 @@ export default class Element extends Node {
|
||||
}
|
||||
});
|
||||
|
||||
if (passiveEvents.has(handler.name) && !handler.usesEventObject) {
|
||||
if (passiveEvents.has(handler.name) && !handler.usesEventObject && !handler.modifiers.has('preventDefault')) {
|
||||
// touch/wheel events should be passive by default
|
||||
handler.modifiers.add('passive');
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
[{
|
||||
"message": "The 'passive' and 'preventDefault' modifiers cannot be used together",
|
||||
"code": "invalid-event-modifier",
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 5,
|
||||
"character": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 52,
|
||||
"character": 52
|
||||
},
|
||||
"pos": 5
|
||||
}]
|
@ -0,0 +1,3 @@
|
||||
<div on:wheel|passive|preventDefault="handleWheel()">
|
||||
oops
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user