|
8 | 8 | onDeactivated, |
9 | 9 | onMounted, |
10 | 10 | onUnmounted, |
| 11 | + provide, |
11 | 12 | ref, |
12 | 13 | toDisplayString, |
13 | 14 | } from '@vue/runtime-dom' |
@@ -1064,6 +1065,44 @@ describe('hot module replacement', () => { |
1064 | 1065 | ) |
1065 | 1066 | }) |
1066 | 1067 |
|
| 1068 | + // Vapor router-view has no render function (setup-only). |
| 1069 | + // When HMR rerender is triggered, the setup function is re-executed. |
| 1070 | + // Ensure provide() warning is suppressed. |
| 1071 | + test('rerender setup-only component', async () => { |
| 1072 | + const childId = 'test-child-reload-01' |
| 1073 | + const Child = defineVaporComponent({ |
| 1074 | + __hmrId: childId, |
| 1075 | + render: compileToFunction(`<div>foo</div>`), |
| 1076 | + }) |
| 1077 | + createRecord(childId, Child as any) |
| 1078 | + |
| 1079 | + // without a render function |
| 1080 | + const Parent = defineVaporComponent({ |
| 1081 | + setup() { |
| 1082 | + provide('foo', 'bar') |
| 1083 | + return createComponent(Child) |
| 1084 | + }, |
| 1085 | + }) |
| 1086 | + |
| 1087 | + const { html } = define({ |
| 1088 | + setup() { |
| 1089 | + return createComponent(Parent) |
| 1090 | + }, |
| 1091 | + }).render() |
| 1092 | + |
| 1093 | + expect(html()).toBe('<div>foo</div>') |
| 1094 | + |
| 1095 | + // will trigger parent rerender |
| 1096 | + reload(childId, { |
| 1097 | + __hmrId: childId, |
| 1098 | + render: compileToFunction(`<div>bar</div>`), |
| 1099 | + }) |
| 1100 | + |
| 1101 | + await nextTick() |
| 1102 | + expect(html()).toBe('<div>bar</div>') |
| 1103 | + expect('provide() can only be used inside setup()').not.toHaveBeenWarned() |
| 1104 | + }) |
| 1105 | + |
1067 | 1106 | describe('switch vapor/vdom modes', () => { |
1068 | 1107 | test('vapor -> vdom', async () => { |
1069 | 1108 | const id = 'vapor-to-vdom' |
|
0 commit comments