Skip to content

Commit 42dc999

Browse files
committed
test bind-el
1 parent a9af6c0 commit 42dc999

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/directives/el.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ module.exports = {
1111
var id = this.id = this.arg // bind-el ?
1212
? scope.$eval(this.expression)
1313
: this.expression
14+
15+
if (process.env.NODE_ENV !== 'production' && this.arg) {
16+
_.log(
17+
'You are using bind- syntax on "el", which is a special ' +
18+
'attribute. It will be evaluated only once.'
19+
)
20+
}
21+
1422
if (refs.hasOwnProperty(id)) {
1523
refs[id] = this.el
1624
} else {

test/unit/specs/directives/el_spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if (_.inBrowser) {
88
beforeEach(function () {
99
el = document.createElement('div')
1010
spyOn(_, 'warn')
11+
spyOn(_, 'log')
1112
})
1213

1314
it('normal', function () {
@@ -42,6 +43,19 @@ if (_.inBrowser) {
4243
})
4344
})
4445

46+
it('bind-el', function () {
47+
var vm = new Vue({
48+
el: el,
49+
data: {
50+
id: 'test'
51+
},
52+
template: '<div bind-el="id" id="test"></div>'
53+
})
54+
expect(vm.$$.test).toBeTruthy()
55+
expect(vm.$$.test.id).toBe('test')
56+
expect(_.log).toHaveBeenCalled()
57+
})
58+
4559
it('with v-repeat', function (done) {
4660
var vm = new Vue({
4761
el: el,

0 commit comments

Comments
 (0)