Skip to content

Commit

Permalink
pass createElement into render functions
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 17, 2016
1 parent 6a3430d commit 41e4647
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/core/instance/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function renderMixin (Vue: Class<Component>) {
resolveSlots(vm, _renderChildren)
}
// render self
let vnode = render.call(vm._renderProxy)
let vnode = render.call(vm._renderProxy, vm.$createElement)
// return empty vnode in case the render function errored out
if (!(vnode instanceof VNode)) {
if (process.env.NODE_ENV !== 'production' && Array.isArray(vnode)) {
Expand Down
6 changes: 2 additions & 4 deletions test/unit/features/directives/on.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ describe('Directive v-on', () => {
data: {
ok: true
},
render () {
const h = this.$createElement
render (h) {
return this.ok
? h('input', { on: { click: this.foo }})
: h('input', { on: { input: this.bar }})
Expand Down Expand Up @@ -155,8 +154,7 @@ describe('Directive v-on', () => {
template: '<div></div>'
}
},
render () {
const h = this.$createElement
render (h) {
return this.ok
? h('test', { on: { foo: this.foo }})
: h('test', { on: { bar: this.bar }})
Expand Down
3 changes: 1 addition & 2 deletions test/unit/features/directives/ref.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ describe('Directive v-ref', () => {
it('should work as a hyperscript prop', () => {
const vm = new Vue({
components,
render () {
const h = this.$createElement
render (h) {
return h('div', null, [
h('test', { ref: 'test' })
])
Expand Down
3 changes: 1 addition & 2 deletions test/unit/features/options/el.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ describe('Options el', () => {
el.innerHTML = '<span>{{message}}</span>'
const vm = new Vue({
el,
render () {
const h = this.$createElement
render (h) {
return h('p', { staticAttrs: { id: 'app' }}, [
h('span', {}, [this.message])
])
Expand Down
6 changes: 2 additions & 4 deletions test/unit/features/options/render.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import Vue from 'entries/web-runtime'
describe('Options render', () => {
it('basic usage', () => {
const vm = new Vue({
render () {
const h = this.$createElement
render (h) {
const children = []
for (let i = 0; i < this.items.length; i++) {
children.push(h('li', { staticClass: 'task' }, [this.items[i].name]))
Expand All @@ -25,8 +24,7 @@ describe('Options render', () => {

it('allow null data', () => {
const vm = new Vue({
render () {
const h = this.$createElement
render (h) {
return h('div', null, 'hello' /* string as children*/)
}
}).$mount()
Expand Down

0 comments on commit 41e4647

Please sign in to comment.