-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Modifier once for v-on #4267
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
Modifier once for v-on #4267
Changes from 2 commits
587e7bd
2da2a9d
a900c52
53c14db
4f78719
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,24 @@ describe('Directive v-on', () => { | |
expect(callOrder.toString()).toBe('1,2') | ||
}) | ||
|
||
it('should support once', () => { | ||
const numberPushed = [] | ||
vm = new Vue({ | ||
el, | ||
template: ` | ||
<div @click.once="foo"> | ||
</div> | ||
`, | ||
methods: { | ||
foo () { numberPushed.push(1) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you could create a jasmine.createSpy(), and use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait for it, sir. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've made changes to this pr locally, but while running the unit test, encountered with some problem:
The second assertion fails. Will the second assertion be misjudged by the first call?
Both of the assertions in this test success. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Figured out that, in this case, should use spy.calls.count(). |
||
} | ||
}) | ||
triggerEvent(vm.$el, 'click') | ||
expect(numberPushed.toString()).toBe('1') | ||
triggerEvent(vm.$el, 'click') | ||
expect(numberPushed.toString()).toBe('1') | ||
}) | ||
|
||
it('should support keyCode', () => { | ||
vm = new Vue({ | ||
el, | ||
|
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.
why not just remove the event handle after invoked?
Uh oh!
There was an error while loading. Please reload this page.
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.
That's a good question.
Actually, some bugs were found and the pr is way not completed. I'm still working on it.