render,
withModifiers,
} from '@vue/runtime-dom'
+import { createApp } from 'vue'
import { PatchFlags } from '@vue/shared'
describe('attribute fallthrough', () => {
expect(textBar).toBe('from GrandChild')
expect(textFoo).toBe('from Child')
})
+
+ // covers uncaught regression #10710
+ it('should track this.$attrs access in slots', async () => {
+ const GrandChild = {
+ template: `<slot/>`,
+ }
+ const Child = {
+ components: { GrandChild },
+ template: `<div><GrandChild>{{ $attrs.foo }}</GrandChild></div>`,
+ }
+
+ const obj = ref(1)
+ const App = {
+ render() {
+ return h(Child, { foo: obj.value })
+ },
+ }
+
+ const root = document.createElement('div')
+ createApp(App).mount(root)
+
+ expect(root.innerHTML).toBe('<div foo="1">1</div>')
+
+ obj.value = 2
+ await nextTick()
+ expect(root.innerHTML).toBe('<div foo="2">2</div>')
+ })
})
// public $xxx properties
if (publicGetter) {
if (key === '$attrs') {
- track(instance, TrackOpTypes.GET, key)
+ track(instance.attrs, TrackOpTypes.GET, '')
__DEV__ && markAttrsAccessed()
} else if (__DEV__ && key === '$slots') {
+ // for HMR only
track(instance, TrackOpTypes.GET, key)
}
return publicGetter(instance)