diff --git a/flow/compiler.js b/flow/compiler.js index bc40b45c4..bdd013198 100644 --- a/flow/compiler.js +++ b/flow/compiler.js @@ -84,10 +84,6 @@ declare type ASTElement = { ref?: string, refInFor?: boolean, - render?: true, - renderMethod?: ?string, - renderArgs?: ?string, - if?: string, ifProcessed?: boolean, else?: true, diff --git a/src/compiler/codegen.js b/src/compiler/codegen.js index b7322e163..382a35eec 100644 --- a/src/compiler/codegen.js +++ b/src/compiler/codegen.js @@ -45,8 +45,6 @@ function genElement (el: ASTElement): string { return genIf(el) } else if (el.tag === 'template' && !el.slotTarget) { return genChildren(el) || 'void 0' - } else if (el.tag === 'render') { - return genRender(el) } else if (el.tag === 'slot') { return genSlot(el) } else { @@ -245,18 +243,6 @@ function genText (text: ASTText | ASTExpression): string { : '_t(' + JSON.stringify(text.text) + ')' } -function genRender (el: ASTElement): string { - if (!el.renderMethod) { - return 'void 0' - } - const children = genChildren(el) - return `${el.renderMethod}(${ - el.renderArgs || '' - }${ - children ? (el.renderArgs ? ',' : '') + children : '' - })` -} - function genSlot (el: ASTElement): string { const slot = `$slots[${el.slotName || '"default"'}]` const children = genChildren(el) diff --git a/src/compiler/parser/index.js b/src/compiler/parser/index.js index 5c060746f..219e891eb 100644 --- a/src/compiler/parser/index.js +++ b/src/compiler/parser/index.js @@ -123,7 +123,6 @@ export function parse ( // determine whether this is a plain element after // removing if/for/once attributes element.plain = !element.key && !attrs.length - processRender(element) processSlot(element) processComponent(element) for (let i = 0; i < transforms.length; i++) { @@ -145,8 +144,8 @@ export function parse ( } if (element.attrsMap.hasOwnProperty('v-for')) { warn( - 'Cannot use v-for on component root element because it renders ' + - 'multiple elements:\n' + template + 'Cannot use v-for on stateful component root element because ' + + 'it renders multiple elements:\n' + template ) } } @@ -306,24 +305,6 @@ function processOnce (el) { } } -function processRender (el) { - if (el.tag === 'render') { - el.render = true - el.renderMethod = el.attrsMap[':method'] || el.attrsMap['v-bind:method'] - el.renderArgs = el.attrsMap[':args'] || el.attrsMap['v-bind:args'] - if (process.env.NODE_ENV !== 'production') { - if (el.attrsMap.method) { - warn(' method should use a dynamic binding, e.g. `:method="..."`.') - } else if (!el.renderMethod) { - warn('method attribute is required on .') - } - if (el.attrsMap.args) { - warn(' args should use a dynamic binding, e.g. `:args="..."`.') - } - } - } -} - function processSlot (el) { if (el.tag === 'slot') { el.slotName = getBindingAttr(el, 'name') diff --git a/test/unit/features/render/render.spec.js b/test/unit/features/render/render.spec.js deleted file mode 100644 index c3bd42cd4..000000000 --- a/test/unit/features/render/render.spec.js +++ /dev/null @@ -1,134 +0,0 @@ -import Vue from 'vue' - -describe('Render', () => { - it('render with basic usage', () => { - const vm = new Vue({ - template: `
`, - methods: { - onRender (args) { return args } - } - }).$mount() - expect(vm.$el.tagName).toBe('DIV') - expect(vm.$el.innerHTML).toBe('hello') - }) - - it('should render with $createElement', () => { - const vm = new Vue({ - template: `
`, - data: { message: 'hello world' }, - methods: { - onRender (args) { - const h = this.$createElement - return h('div', { class: 'message' }, [ - h('p', {}, [args]) - ]) - } - } - }).$mount() - expect(vm.$el.childNodes[0].tagName).toBe('DIV') - expect(vm.$el.childNodes[0]).toHaveClass('message') - expect(vm.$el.childNodes[0].childNodes[0].tagName).toBe('P') - expect(vm.$el.childNodes[0].childNodes[0].textContent).toBe('hello world') - }) - - it('should render with inline elements', () => { - const vm = new Vue({ - template: ` - -
    -
  • -
-
- `, - data: { message: 'hello world' }, - methods: { - onRender (args, children) { - const ul = children[0] - ul.children.forEach((li, i) => { - li.data = { staticClass: `class${i}` } - }) - return ul - } - } - }).$mount() - const ul = vm.$el - expect(ul.tagName).toBe('UL') - for (let i = 0; i < ul.children.length; i++) { - const li = ul.children[i] - expect(li.tagName).toBe('LI') - expect(li).toHaveClass(`class${i}`) - } - }) - - it('should render component', done => { - const modal = { - template: ` - - - `, - props: { - title: { - type: String, default: 'title1' - } - } - } - const vm = new Vue({ - template: `
`, - data: { - shown: true, - title: 'hello modal' - }, - components: { modal }, - methods: { - onRenderModal (title) { - return this.$createElement('modal', { - props: { title: title }, - on: { close: this.onCloseModal }, - directives: [{ name: 'show', value: this.shown }] - }) - }, - onCloseModal () { this.shown = false } - } - }).$mount() - expect(vm.$el.querySelector('.modal-title').textContent).toBe(vm.title) - vm.$el.querySelector('.modal-action-close').click() - waitForUpdate(() => { - expect(vm.shown).toBe(false) - }).then(() => { - expect(vm.$el.querySelector('.modal-container').style.display).toBe('none') - }).then(done) - }) - - it('should warn no method', () => { - new Vue({ - template: '' - }).$mount() - expect('method attribute is required on ').toHaveBeenWarned() - }) - - it('should warn method/arg usage without v-bind', () => { - new Vue({ - template: '' - }).$mount() - expect(' method should use a dynamic binding').toHaveBeenWarned() - }) - - it('should warn non dynamic args', () => { - new Vue({ - template: '', - methods: { - a: () => {} - } - }).$mount() - expect(' args should use a dynamic binding').toHaveBeenWarned() - }) -}) diff --git a/test/unit/modules/compiler/codegen.spec.js b/test/unit/modules/compiler/codegen.spec.js index c3873b754..5dc1122d1 100644 --- a/test/unit/modules/compiler/codegen.spec.js +++ b/test/unit/modules/compiler/codegen.spec.js @@ -113,28 +113,6 @@ describe('codegen', () => { ) }) - it('generate render tag', () => { - assertCodegen( - '', - `with(this){return onRender(params)}` - ) - }) - - it('generate render tag that have children', () => { - assertCodegen( - '

hello

', - `with(this){return onRender([_m(0)])}`, - [`with(this){return _h(_e('p'),[_t("hello")])}`] - ) - }) - - it('generate render tag with `method` is not dynamic binding', () => { - assertCodegen( - '', - `with(this){return void 0}` - ) - }) - it('generate single slot', () => { assertCodegen( '', diff --git a/test/unit/modules/compiler/parser.spec.js b/test/unit/modules/compiler/parser.spec.js index ea86eb7fa..268ae6a48 100644 --- a/test/unit/modules/compiler/parser.spec.js +++ b/test/unit/modules/compiler/parser.spec.js @@ -89,7 +89,7 @@ describe('parser', () => { it('warn v-for on root element', () => { parse('
', baseOptions) - expect('Cannot use v-for on component root element').toHaveBeenWarned() + expect('Cannot use v-for on stateful component root element').toHaveBeenWarned() }) it('v-pre directive', () => { @@ -162,28 +162,6 @@ describe('parser', () => { expect(ast.once).toBe(true) }) - it('render tag syntax', () => { - const ast = parse('', baseOptions) - expect(ast.render).toBe(true) - expect(ast.renderMethod).toBe('onRender') - expect(ast.renderArgs).toBe('params') - }) - - it('render tag invalid syntax', () => { - // method nothing - const invalidAst1 = parse('', baseOptions) - expect('method attribute is required on .').toHaveBeenWarned() - expect(invalidAst1.render).toBe(true) - expect(invalidAst1.renderMethod).toBeUndefined() - expect(invalidAst1.renderArgs).toBeUndefined() - // method no dynamic binding - parse('', baseOptions) - expect(' method should use a dynamic binding').toHaveBeenWarned() - // args no dynamic binding - parse('', baseOptions) - expect(' args should use a dynamic binding').toHaveBeenWarned() - }) - it('slot tag single syntax', () => { const ast = parse('', baseOptions) expect(ast.tag).toBe('slot')