-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(runtime-core): remove emit return value
BREAKING CHANGE: this.$emit() and setupContext.emit() no longer return values. For logic that relies on return value of listeners, the listener should be declared as an `onXXX` prop and be called directly. This still allows the parent component to pass in a handler using `v-on`, since `v-on:foo` internally compiles to `onFoo`. ref: vuejs/rfcs#16
- Loading branch information
Showing
5 changed files
with
95 additions
and
166 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { ref, render, h, nodeOps, nextTick } from '@vue/runtime-test' | ||
|
||
describe('component: slots', () => { | ||
// TODO more tests for slots normalization etc. | ||
|
||
test('should respect $stable flag', async () => { | ||
const flag1 = ref(1) | ||
const flag2 = ref(2) | ||
const spy = jest.fn() | ||
|
||
const Child = () => { | ||
spy() | ||
return 'child' | ||
} | ||
|
||
const App = { | ||
setup() { | ||
return () => [ | ||
flag1.value, | ||
h( | ||
Child, | ||
{ n: flag2.value }, | ||
{ | ||
foo: () => 'foo', | ||
$stable: true | ||
} | ||
) | ||
] | ||
} | ||
} | ||
|
||
render(h(App), nodeOps.createElement('div')) | ||
expect(spy).toHaveBeenCalledTimes(1) | ||
|
||
// parent re-render, props didn't change, slots are stable | ||
// -> child should not update | ||
flag1.value++ | ||
await nextTick() | ||
expect(spy).toHaveBeenCalledTimes(1) | ||
|
||
// parent re-render, props changed | ||
// -> child should update | ||
flag2.value++ | ||
await nextTick() | ||
expect(spy).toHaveBeenCalledTimes(2) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters