Description
Version
2.6.11
Reproduction link
https://jsfiddle.net/adamsol/pknr8dae/
Steps to reproduce
Click the buttons.
What is expected?
All the buttons should behave in the same way: a message should appear below.
What is actually happening?
Only the first button works correctly.
See #11893 for the origin of the issue.
The problem lies probably here:
vue/packages/vue-template-compiler/build.js
Line 3801 in 5255841
The regexes used do not take into account cases such as additional spaces, parentheses, or chained function invocations. As a result, a promise is correctly returned only in the first case in the repro, and in all the other cases errorHandler
won't capture the exception thrown in the async method.
The difference in the generated code (return
is present only in the first case): https://template-explorer.vuejs.org/#%3Cdiv%20id%3D%22app%22%3E%0A%20%20%3Cbutton%20%40click%3D%22click(1)%22%3E%0A%20%20%20%20click(1)%0A%20%20%3C%2Fbutton%3E%0A%20%20%3Cbutton%20%40click%3D%22click%20(2)%22%3E%0A%20%20%20%20click%20(2)%0A%20%20%3C%2Fbutton%3E%0A%20%20%3Cbutton%20%40click%3D%22click((3))%22%3E%0A%20%20%20%20click((3))%0A%20%20%3C%2Fbutton%3E%0A%20%20%3Cbutton%20%40click%3D%22(click(4))%22%3E%0A%20%20%20%20(click(4))%0A%20%20%3C%2Fbutton%3E%0A%20%20%3Cbutton%20%40click%3D%22click(5).then()%22%3E%0A%20%20%20%20click(5).then()%0A%20%20%3C%2Fbutton%3E%0A%3C%2Fdiv%3E
Suggested solution: either add return
in every case, or don't add it at all, so that the behaviour is consistent. If checking for the function invocation is crucial, then the code must be parsed in some other way.