Subscribe on changes!

@touchstart cause warn message in chrome console

avatar
May 17th 2021

Version

3.1.1

Reproduction link

Vue SFC Playground

Steps to reproduce

set a @touchstart="..." on any element

What is expected?

no warn message

What is actually happening?

Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952

Any additional comments?

If we explicitly set passive: false, there is no warning. Maybe add a 'non-passive' modifier or explicitly set passive: false if passive modifier is not set.

avatar
May 17th 2021

Why not just actually register it as @touchstart.passive? That's what the warning is about. You should use passive touch event listeners.

I don't see a point in providing a way to do passive: false since its only purpose is to intentionally suppress a warning with worse performance for end users?

avatar
May 17th 2021

@yyx990803 I don't really agree, sometimes it may be necessary to use preventdefault on a touch / mouse event to avoid side effects with the operating system. For example, the gif below shows accidental history triggering when passive is set to true on chromeOS, very annoying.

Imgur

In addition, it is not something forbidden, it is just strongly discouraged to use a non-passive event in certain use cases (eg. Heavy calculation during a scroll). It is a choice which I think should be taken by the developer.

Really annoying to have warnings when using something knowingly

avatar
Jan 21st 2023

With chrome < 100, I have just tested with the latest and indeed no more warnings :)

Le ven. 20 janv. 2023 à 19:05, Amit Patel @.***> a écrit :

Which browser are you seeing this in? I tried your sfc link and am not seeing this warning in Chrome 109. Is it possible they removed the warning in a recent version?

— Reply to this email directly, view it on GitHub https://github.com/vuejs/core/issues/3786#issuecomment-1398754966, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAY6K2TNKIA36UGLLAOKGLDWTLHX7ANCNFSM45A3YDRQ . You are receiving this because you authored the thread.Message ID: @.***>