File tree 3 files changed +65
-6
lines changed
3 files changed +65
-6
lines changed Original file line number Diff line number Diff line change
1
+ import {
2
+ createComponent ,
3
+ defineComponent ,
4
+ getCurrentInstance ,
5
+ nextTick ,
6
+ ref ,
7
+ setText ,
8
+ template ,
9
+ toRefs ,
10
+ watch ,
11
+ watchEffect ,
12
+ } from '../src'
13
+ import { setCurrentInstance } from '../src/component'
14
+ import { makeRender } from './_utils'
15
+
16
+ const define = makeRender < any > ( )
17
+
18
+ describe ( 'attribute fallthrough' , ( ) => {
19
+ it ( 'should allow attrs to fallthrough' , async ( ) => {
20
+ const t0 = template ( '<div>' )
21
+ const { component : Child } = define ( {
22
+ props : [ 'foo' ] ,
23
+ render ( ) {
24
+ const instance = getCurrentInstance ( ) !
25
+ const n0 = t0 ( )
26
+ watchEffect ( ( ) => setText ( n0 , instance . props . foo ) )
27
+ return n0
28
+ } ,
29
+ } )
30
+
31
+ const foo = ref ( 1 )
32
+ const id = ref ( 'a' )
33
+ const { instance, host } = define ( {
34
+ setup ( ) {
35
+ return { foo, id }
36
+ } ,
37
+ render ( _ctx : Record < string , any > ) {
38
+ return createComponent ( Child , {
39
+ foo : ( ) => _ctx . foo ,
40
+ id : ( ) => _ctx . id ,
41
+ } )
42
+ } ,
43
+ } ) . render ( )
44
+ const reset = setCurrentInstance ( instance )
45
+ expect ( host . innerHTML ) . toBe ( '<div id="a">1</div>' )
46
+
47
+ foo . value ++
48
+ await nextTick ( )
49
+ expect ( host . innerHTML ) . toBe ( '<div id="a">2</div>' )
50
+
51
+ id . value = 'b'
52
+ await nextTick ( )
53
+ expect ( host . innerHTML ) . toBe ( '<div id="b">2</div>' )
54
+ reset ( )
55
+ } )
56
+ } )
Original file line number Diff line number Diff line change @@ -246,17 +246,14 @@ describe('component: props', () => {
246
246
} ,
247
247
} ) . render ( )
248
248
const reset = setCurrentInstance ( instance )
249
- // expect(host.innerHTML).toBe('<div id="a">1</div>') // TODO: Fallthrough Attributes
250
249
expect ( host . innerHTML ) . toBe ( '<div>1</div>' )
251
250
252
251
foo . value ++
253
252
await nextTick ( )
254
- // expect(host.innerHTML).toBe('<div id="a">2</div>') // TODO: Fallthrough Attributes
255
253
expect ( host . innerHTML ) . toBe ( '<div>2</div>' )
256
254
257
255
id . value = 'b'
258
256
await nextTick ( )
259
- // expect(host.innerHTML).toBe('<div id="b">2</div>') // TODO: Fallthrough Attributes
260
257
reset ( )
261
258
} )
262
259
Original file line number Diff line number Diff line change 1
1
import { isArray , isFunction , isObject } from '@vue/shared'
2
2
import { type ComponentInternalInstance , setCurrentInstance } from './component'
3
3
import { insert , querySelector , remove } from './dom/element'
4
- import { flushPostFlushCbs , queuePostRenderEffect } from './scheduler'
5
- import { proxyRefs } from '@vue/reactivity'
4
+ import {
5
+ createVaporPreScheduler ,
6
+ flushPostFlushCbs ,
7
+ queuePostRenderEffect ,
8
+ } from './scheduler'
9
+ import { baseWatch , proxyRefs } from '@vue/reactivity'
6
10
import { invokeLifecycle } from './componentLifecycle'
7
11
import { VaporLifecycleHooks } from './apiLifecycle'
8
12
import { fallThroughAttrs } from './componentAttrs'
@@ -50,7 +54,9 @@ export function setupComponent(instance: ComponentInternalInstance): void {
50
54
}
51
55
instance . block = block
52
56
if ( instance . inheritAttrs !== false ) {
53
- fallThroughAttrs ( instance )
57
+ baseWatch ( ( ) => fallThroughAttrs ( instance ) , undefined , {
58
+ scheduler : createVaporPreScheduler ( instance ) ,
59
+ } )
54
60
}
55
61
return block
56
62
} )
You can’t perform that action at this time.
0 commit comments