Performance: Mouse button modifiers
MEDIUM IMPACT
This affects how efficiently mouse events are handled and filtered in the browser, impacting interaction responsiveness.
<template> <button @click.left="handleLeftClick">Click me</button> </template> <script setup> function handleLeftClick() { console.log('Left click detected'); } </script>
<template> <button @click="handleClick">Click me</button> </template> <script setup> function handleClick(event) { if (event.button === 0) { console.log('Left click detected'); } } </script>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Handling all clicks and filtering in handler | 1 event listener | 0 | 0 | [X] Bad |
| Using Vue .left mouse button modifier | 1 event listener | 0 | 0 | [OK] Good |