This repository was archived by the owner on Jul 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +65
-6
lines changed Expand file tree Collapse file tree 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', () => {
246246 } ,
247247 } ) . render ( )
248248 const reset = setCurrentInstance ( instance )
249- // expect(host.innerHTML).toBe('<div id="a">1</div>') // TODO: Fallthrough Attributes
250249 expect ( host . innerHTML ) . toBe ( '<div>1</div>' )
251250
252251 foo . value ++
253252 await nextTick ( )
254- // expect(host.innerHTML).toBe('<div id="a">2</div>') // TODO: Fallthrough Attributes
255253 expect ( host . innerHTML ) . toBe ( '<div>2</div>' )
256254
257255 id . value = 'b'
258256 await nextTick ( )
259- // expect(host.innerHTML).toBe('<div id="b">2</div>') // TODO: Fallthrough Attributes
260257 reset ( )
261258 } )
262259
Original file line number Diff line number Diff line change 11import { isArray , isFunction , isObject } from '@vue/shared'
22import { type ComponentInternalInstance , setCurrentInstance } from './component'
33import { 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'
610import { invokeLifecycle } from './componentLifecycle'
711import { VaporLifecycleHooks } from './apiLifecycle'
812import { fallThroughAttrs } from './componentAttrs'
@@ -50,7 +54,9 @@ export function setupComponent(instance: ComponentInternalInstance): void {
5054 }
5155 instance . block = block
5256 if ( instance . inheritAttrs !== false ) {
53- fallThroughAttrs ( instance )
57+ baseWatch ( ( ) => fallThroughAttrs ( instance ) , undefined , {
58+ scheduler : createVaporPreScheduler ( instance ) ,
59+ } )
5460 }
5561 return block
5662 } )
You can’t perform that action at this time.
0 commit comments