Browse Source
New features intended for easier creation of higher-order components. - New instance properties: $attrs & $listeners. these are essentially aliases of $vnode.data.attrs and $vnode.data.on, but are reactive. - New component option: inheritAttrs. Turns off the default behavior where parent scope non-prop bindings are automatically inherited on component root as attributes. close #5983.dev
Evan You
7 years ago
10 changed files with 149 additions and 20 deletions
@ -0,0 +1,39 @@ |
|||
import Vue from 'vue' |
|||
|
|||
describe('Options inheritAttrs', () => { |
|||
it('should work', done => { |
|||
const vm = new Vue({ |
|||
template: `<foo :id="foo"/>`, |
|||
data: { foo: 'foo' }, |
|||
components: { |
|||
foo: { |
|||
inheritAttrs: false, |
|||
template: `<div>foo</div>` |
|||
} |
|||
} |
|||
}).$mount() |
|||
expect(vm.$el.id).toBe('') |
|||
vm.foo = 'bar' |
|||
waitForUpdate(() => { |
|||
expect(vm.$el.id).toBe('') |
|||
}).then(done) |
|||
}) |
|||
|
|||
it('with inner v-bind', done => { |
|||
const vm = new Vue({ |
|||
template: `<foo :id="foo"/>`, |
|||
data: { foo: 'foo' }, |
|||
components: { |
|||
foo: { |
|||
inheritAttrs: false, |
|||
template: `<div><div v-bind="$attrs"></div></div>` |
|||
} |
|||
} |
|||
}).$mount() |
|||
expect(vm.$el.children[0].id).toBe('foo') |
|||
vm.foo = 'bar' |
|||
waitForUpdate(() => { |
|||
expect(vm.$el.children[0].id).toBe('bar') |
|||
}).then(done) |
|||
}) |
|||
}) |
Loading…
Reference in new issue