Procházet zdrojové kódy

isFn -> acceptStatement

Evan You před 11 roky
rodič
revize
2a18cf0f4e
4 změnil soubory, kde provedl 17 přidání a 7 odebrání
  1. 11 1
      changes.md
  2. 3 3
      src/directive.js
  3. 1 1
      src/directives/on.js
  4. 2 2
      test/unit/specs/directive_spec.js

+ 11 - 1
changes.md

@@ -395,7 +395,17 @@ computed: {
 
   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.
 
-- #### Removed directive option: `isEmpty`
+- #### New directive option: `acceptStatement`
+
+  This option indicates the directive accepts inline statements like `v-on` does:
+
+  ``` html
+  <a v-on="click: a++"></a>
+  ```
+
+  The statement will be wrapped up as a function and passed as the argument to the directive's `update` function.
+
+- #### Removed directive option: `isEmpty`, `isFn`
 
 ## Interpolation change
 

+ 3 - 3
src/directive.js

@@ -63,7 +63,7 @@ p._bind = function (def) {
   if (
     this.update && this._watcherExp &&
     (!this.isLiteral || this._isDynamicLiteral) &&
-    !this._checkExpFn()
+    !this._checkStatement()
   ) {
     // use raw expression as identifier because filters
     // make them different watchers
@@ -122,10 +122,10 @@ p._checkDynamicLiteral = function () {
  * @return {Boolean}
  */
 
-p._checkExpFn = function () {
+p._checkStatement = function () {
   var expression = this.expression
   if (
-    expression && this.isFn &&
+    expression && this.acceptStatement &&
     !expParser.pathTestRE.test(expression)
   ) {
     var fn = expParser.parse(expression).get

+ 1 - 1
src/directives/on.js

@@ -2,7 +2,7 @@ var _ = require('../util')
 
 module.exports = {
 
-  isFn: true,
+  acceptStatement: true,
   priority: 700,
 
   bind: function () {

+ 2 - 2
test/unit/specs/directive_spec.js

@@ -97,8 +97,8 @@ describe('Directive', function () {
     })
   })
 
-  it('expression function', function () {
-    def.isFn = true
+  it('inline statement', function () {
+    def.acceptStatement = true
     var spy = jasmine.createSpy()
     vm.$options.filters.test = function (fn) {
       spy()