-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): $attrs, $listeners & inheritAttrs option
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.
- Loading branch information
Showing
10 changed files
with
149 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters