disallow once/passive in legacy mode, for now

pull/1819/head
Rich Harris 6 years ago
parent aa203973e0
commit 8ec02b336d

@ -613,6 +613,15 @@ export default class Element extends Node {
});
}
}
if (component.options.legacy && (modifier === 'once' || modifier === 'passive')) {
// TODO this could be supported, but it would need a few changes to
// how event listeners work
component.error(handler, {
code: 'invalid-event-modifier',
message: `The '${modifier}' modifier cannot be used in legacy mode`
});
}
});
});
}

@ -32,6 +32,7 @@ describe("validate", () => {
warnings.push({ code, message, pos, start, end });
},
dev: config.dev,
legacy: config.legacy,
generate: false
});

@ -1,15 +1,15 @@
[{
"message": "Valid event modifiers are preventDefault, stopPropagation, capture, once or passive",
"code": "invalid-event-modifier",
"start": {
"line": 1,
"column": 8,
"character": 8
},
"end": {
"line": 1,
"column": 36,
"character": 36
},
"pos": 8
}]
"message": "Valid event modifiers are preventDefault, stopPropagation, capture, once or passive",
"code": "invalid-event-modifier",
"start": {
"line": 1,
"column": 8,
"character": 8
},
"end": {
"line": 1,
"column": 36,
"character": 36
},
"pos": 8
}]

@ -0,0 +1,3 @@
export default {
legacy: true
};

@ -0,0 +1,15 @@
[{
"message": "The 'once' modifier cannot be used in legacy mode",
"code": "invalid-event-modifier",
"start": {
"line": 1,
"column": 8,
"character": 8
},
"end": {
"line": 1,
"column": 37,
"character": 37
},
"pos": 8
}]

@ -0,0 +1 @@
<button on:click|once="handleClick()"></button>
Loading…
Cancel
Save