inheritAttrs.spec.js 904 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import Vue from 'vue'
  2. describe('Options inheritAttrs', () => {
  3. it('should work', done => {
  4. const vm = new Vue({
  5. template: `<foo :id="foo"/>`,
  6. data: { foo: 'foo' },
  7. components: {
  8. foo: {
  9. inheritAttrs: false,
  10. template: `<div>foo</div>`
  11. }
  12. }
  13. }).$mount()
  14. expect(vm.$el.id).toBe('')
  15. vm.foo = 'bar'
  16. waitForUpdate(() => {
  17. expect(vm.$el.id).toBe('')
  18. }).then(done)
  19. })
  20. it('with inner v-bind', done => {
  21. const vm = new Vue({
  22. template: `<foo :id="foo"/>`,
  23. data: { foo: 'foo' },
  24. components: {
  25. foo: {
  26. inheritAttrs: false,
  27. template: `<div><div v-bind="$attrs"></div></div>`
  28. }
  29. }
  30. }).$mount()
  31. expect(vm.$el.children[0].id).toBe('foo')
  32. vm.foo = 'bar'
  33. waitForUpdate(() => {
  34. expect(vm.$el.children[0].id).toBe('bar')
  35. }).then(done)
  36. })
  37. })