Added nonpassive as an event modifier

linting

linting
pull/5442/head
filipot 5 years ago committed by Tan Li Hau
parent b5b02f8561
commit 5ed6666fa6

@ -80,7 +80,8 @@ const valid_modifiers = new Set([
'capture', 'capture',
'once', 'once',
'passive', 'passive',
'self' 'nonpassive',
'self',
]); ]);
const passive_events = new Set([ const passive_events = new Set([

@ -45,12 +45,24 @@ export default class EventHandlerWrapper {
const args = []; const args = [];
const opts = ['passive', 'once', 'capture'].filter(mod => this.node.modifiers.has(mod)); const opts = ['nonpassive', 'passive', 'once', 'capture'].filter(mod => this.node.modifiers.has(mod));
if (opts.length) { if (opts.length) {
args.push((opts.length === 1 && opts[0] === 'capture') let opts_as_string;
? TRUE
: x`{ ${opts.map(opt => p`${opt}: true`)} }`); if (opts[0] === 'nonpassive') {
} else if (block.renderer.options.dev) { opts.shift();
if (!opts.includes('passive')) {
opts.push('passive');
}
opts_as_string = opts.map(opt => p`${opt}: ${opt === 'passive' ? false : true}`);
}
else {
opts_as_string = opts.map(opt => p`${opt}: true`);
}
args.push((opts.length === 1 && opts[0] === 'capture') ? TRUE : x`{ ${opts_as_string} }`);
}
else if (block.renderer.options.dev) {
args.push(FALSE); args.push(FALSE);
} }

@ -1,5 +1,5 @@
[{ [{
"message": "Valid event modifiers are preventDefault, stopPropagation, capture, once, passive or self", "message": "Valid event modifiers are preventDefault, stopPropagation, capture, once, passive, nonpassive or self",
"code": "invalid-event-modifier", "code": "invalid-event-modifier",
"start": { "start": {
"line": 1, "line": 1,

Loading…
Cancel
Save