Skip to content

Commit 5574af3

Browse files
committed
fix coverage
1 parent 178203d commit 5574af3

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/directives/public/el.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ module.exports = {
55
priority: 1500,
66

77
bind: function () {
8+
/* istanbul ignore if */
89
if (!this.arg) {
9-
process.env.NODE_ENV !== 'production' && _.warn(
10-
'v-el requires an argument.'
11-
)
1210
return
1311
}
1412
var id = this.id = _.camelize(this.arg)
@@ -21,7 +19,6 @@ module.exports = {
2119
},
2220

2321
unbind: function () {
24-
if (!this.id) return
2522
var refs = (this._scope || this.vm).$els
2623
if (refs[this.id] === this.el) {
2724
refs[this.id] = null

test/unit/specs/directives/public/ref_spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,13 @@ if (_.inBrowser) {
115115
done()
116116
})
117117
})
118+
119+
it('warn when used on non-component node', function () {
120+
new Vue({
121+
el: el,
122+
template: '<div v-ref:test></div>'
123+
})
124+
expect(hasWarned(_, 'must be used on a child component')).toBe(true)
125+
})
118126
})
119127
}

0 commit comments

Comments
 (0)