Skip to content

Commit

Permalink
* [jsfm] fix alibaba#1447, fix binding event bug of components which …
Browse files Browse the repository at this point in the history
…have repeat attribute
  • Loading branch information
zhangquan committed Oct 25, 2016
1 parent 16a66f5 commit 421cc43
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 57 deletions.
3 changes: 1 addition & 2 deletions html5/default/vm/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,7 @@ function bindEvents (vm, el, events) {
console.debug(`[JS Framework] The method "${handler}" is not defined.`)
}
}
const realVm = vm._realParent ? vm._realParent : vm
setEvent(realVm, el, key, handler)
setEvent(vm, el, key, handler)
}
}

Expand Down
55 changes: 0 additions & 55 deletions html5/test/unit/default/vm/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,61 +79,6 @@ describe('bind and fire events', () => {
})
})

it('context of event binding to element width repeat attribute', (done) => {
customComponentMap.foo = {
template: {
type: 'div',
id: 'container',
events: {
click: 'containerClick'
},
children: [
{
type: 'div',
id: 'items',
'repeat': function () { return this.items },
events: {
click: 'itemsClick'
},
children: [
{
type: 'div'
}
]
}
]
},
data: function () {
return {
items: [
{ name: 1 },
{ name: 2 }
]
}
},
methods: {
containerClick: function () {
expect(this).eql(vm)
},
itemsClick: function () {
expect(this).eql(vm)
}
}
}

const app = { doc, customComponentMap }
const vm = new Vm('foo', customComponentMap.foo, { _app: app })

checkReady(vm, function () {
doc.close()
const containerEl = vm.$el('container')
const itemsEl = vm.$el('items')
containerEl.event.click()
itemsEl.event.click()
done()
})
})

it('emit, broadcast and dispatch vm events', (done) => {
customComponentMap.foo = {
template: {
Expand Down

0 comments on commit 421cc43

Please sign in to comment.