-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support v-on passive modifier #5132
Conversation
Kingwl
commented
Mar 8, 2017
•
edited by posva
Loading
edited by posva
- Bugfix
- Feature
- Code style update
- Refactor
- Build-related changes
- Other, please describe:
src/core/util/env.js
Outdated
window.addEventListener('test-passive', null, opts) | ||
} catch (e) {} | ||
} | ||
export const supportsPassive = _supportsPassive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ES export bindings track changes, we can just do
export let supportsPassive = false
// feature detect...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done thanks
@@ -526,4 +526,28 @@ describe('Directive v-on', () => { | |||
expect(spyUp.calls.count()).toBe(1) | |||
expect(spyDown.calls.count()).toBe(1) | |||
}) | |||
|
|||
it('should support passive', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case should only run when the test browser supports passive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Looking good! I'll merge this when we do the next minor release. |
Just a suggestion, since Vue also support |
ping |
src/compiler/helpers.js
Outdated
// warn prevent and passive modifier | ||
if (process.env.NODE_ENV !== 'production' && modifiers && modifiers.prevent && modifiers.passive) { | ||
warn( | ||
'prevent and passive are mutual exclusive.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, what about passive and prevent can't be used together. Passive handler can't prevent default event.
It uses simpler word and explains the reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
src/compiler/helpers.js
Outdated
// warn prevent and passive modifier | ||
if (process.env.NODE_ENV !== 'production' && modifiers && modifiers.prevent && modifiers.passive) { | ||
warn( | ||
'passive and prevent can\t be used together. ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing literal ('
) in can\t
expect(vm.$refs.normal.checked).toBe(false) | ||
expect(vm.$refs.passive.checked).toBe(true) | ||
expect(vm.$refs.exclusive.checked).toBe(true) | ||
expect('passive and prevent can\t be used together. Passive handler can\'t prevent default event.').toHaveBeenWarned() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs minor fix for above suggested text change.
* support v-on passive modifier * fix supportsPassive and run unit when the test browser supports * add mutual exclusive warning * Fix typo * Fix typo * Remove extra line - CS fix