Skip to content

Commit

Permalink
remove <render> tag
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 17, 2016
1 parent d398023 commit e3fb6fe
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 218 deletions.
4 changes: 0 additions & 4 deletions flow/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ declare type ASTElement = {
ref?: string,
refInFor?: boolean,

render?: true,
renderMethod?: ?string,
renderArgs?: ?string,

if?: string,
ifProcessed?: boolean,
else?: true,
Expand Down
14 changes: 0 additions & 14 deletions src/compiler/codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
23 changes: 2 additions & 21 deletions src/compiler/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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
)
}
}
Expand Down Expand Up @@ -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('<render> method should use a dynamic binding, e.g. `:method="..."`.')
} else if (!el.renderMethod) {
warn('method attribute is required on <render>.')
}
if (el.attrsMap.args) {
warn('<render> args should use a dynamic binding, e.g. `:args="..."`.')
}
}
}
}

function processSlot (el) {
if (el.tag === 'slot') {
el.slotName = getBindingAttr(el, 'name')
Expand Down
134 changes: 0 additions & 134 deletions test/unit/features/render/render.spec.js

This file was deleted.

22 changes: 0 additions & 22 deletions test/unit/modules/compiler/codegen.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,28 +113,6 @@ describe('codegen', () => {
)
})

it('generate render tag', () => {
assertCodegen(
'<render :method="onRender" :args="params"></render>',
`with(this){return onRender(params)}`
)
})

it('generate render tag that have children', () => {
assertCodegen(
'<render :method="onRender"><p>hello</p></render>',
`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(
'<render method="onRender"></render>',
`with(this){return void 0}`
)
})

it('generate single slot', () => {
assertCodegen(
'<slot></slot>',
Expand Down
24 changes: 1 addition & 23 deletions test/unit/modules/compiler/parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('parser', () => {

it('warn v-for on root element', () => {
parse('<div v-for="item in items"></div>', 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', () => {
Expand Down Expand Up @@ -162,28 +162,6 @@ describe('parser', () => {
expect(ast.once).toBe(true)
})

it('render tag syntax', () => {
const ast = parse('<render :method="onRender", :args="params"></render>', 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('<render></render>', baseOptions)
expect('method attribute is required on <render>.').toHaveBeenWarned()
expect(invalidAst1.render).toBe(true)
expect(invalidAst1.renderMethod).toBeUndefined()
expect(invalidAst1.renderArgs).toBeUndefined()
// method no dynamic binding
parse('<render method="onRender"></render>', baseOptions)
expect('<render> method should use a dynamic binding').toHaveBeenWarned()
// args no dynamic binding
parse('<render :method="onRender" args="params"></render>', baseOptions)
expect('<render> args should use a dynamic binding').toHaveBeenWarned()
})

it('slot tag single syntax', () => {
const ast = parse('<slot></slot>', baseOptions)
expect(ast.tag).toBe('slot')
Expand Down

2 comments on commit e3fb6fe

@blocka
Copy link

@blocka blocka commented on e3fb6fe Aug 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this feature removed?

@simplesmiler
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blocka functional components serve this purpose now.

Please sign in to comment.