Skip to content

Commit 2a18cf0

Browse files
committed
isFn -> acceptStatement
1 parent b442cee commit 2a18cf0

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

changes.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,17 @@ computed: {
395395
396396
This option indicates the directive is two-way and may write back to the model. Allows the use of `this.set(value)` inside directive functions.
397397
398-
- #### Removed directive option: `isEmpty`
398+
- #### New directive option: `acceptStatement`
399+
400+
This option indicates the directive accepts inline statements like `v-on` does:
401+
402+
``` html
403+
<a v-on="click: a++"></a>
404+
```
405+
406+
The statement will be wrapped up as a function and passed as the argument to the directive's `update` function.
407+
408+
- #### Removed directive option: `isEmpty`, `isFn`
399409

400410
## Interpolation change
401411

src/directive.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ p._bind = function (def) {
6363
if (
6464
this.update && this._watcherExp &&
6565
(!this.isLiteral || this._isDynamicLiteral) &&
66-
!this._checkExpFn()
66+
!this._checkStatement()
6767
) {
6868
// use raw expression as identifier because filters
6969
// make them different watchers
@@ -122,10 +122,10 @@ p._checkDynamicLiteral = function () {
122122
* @return {Boolean}
123123
*/
124124

125-
p._checkExpFn = function () {
125+
p._checkStatement = function () {
126126
var expression = this.expression
127127
if (
128-
expression && this.isFn &&
128+
expression && this.acceptStatement &&
129129
!expParser.pathTestRE.test(expression)
130130
) {
131131
var fn = expParser.parse(expression).get

src/directives/on.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var _ = require('../util')
22

33
module.exports = {
44

5-
isFn: true,
5+
acceptStatement: true,
66
priority: 700,
77

88
bind: function () {

test/unit/specs/directive_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ describe('Directive', function () {
9797
})
9898
})
9999

100-
it('expression function', function () {
101-
def.isFn = true
100+
it('inline statement', function () {
101+
def.acceptStatement = true
102102
var spy = jasmine.createSpy()
103103
vm.$options.filters.test = function (fn) {
104104
spy()

0 commit comments

Comments
 (0)