Browse Source

isSimple -> isEmpty

Evan You 12 năm trước cách đây
mục cha
commit
f8e31f38b9
4 tập tin đã thay đổi với 8 bổ sung8 xóa
  1. 2 2
      src/compiler.js
  2. 4 4
      src/directive.js
  3. 1 1
      src/directives/with.js
  4. 1 1
      test/unit/specs/directive.js

+ 2 - 2
src/compiler.js

@@ -391,7 +391,7 @@ CompilerProto.bindDirective = function (directive) {
 
     // for a simple directive, simply call its bind() or _update()
     // and we're done.
-    if (directive.isSimple) {
+    if (directive.isEmpty) {
         if (directive.bind) directive.bind()
         return
     }
@@ -605,7 +605,7 @@ CompilerProto.destroy = function () {
         // if this directive is an instance of an external binding
         // e.g. a directive that refers to a variable on the parent VM
         // we need to remove it from that binding's instances
-        if (!dir.isSimple && dir.binding.compiler !== compiler) {
+        if (!dir.isEmpty && dir.binding.compiler !== compiler) {
             instances = dir.binding.instances
             if (instances) instances.splice(instances.indexOf(dir), 1)
         }

+ 4 - 4
src/directive.js

@@ -27,11 +27,11 @@ function Directive (definition, expression, rawKey, compiler, node) {
     this.vm       = compiler.vm
     this.el       = node
 
-    var isSimple  = expression === ''
+    var isEmpty  = expression === ''
 
     // mix in properties from the directive definition
     if (typeof definition === 'function') {
-        this[isSimple ? 'bind' : '_update'] = definition
+        this[isEmpty ? 'bind' : '_update'] = definition
     } else {
         for (var prop in definition) {
             if (prop === 'unbind' || prop === 'update') {
@@ -43,8 +43,8 @@ function Directive (definition, expression, rawKey, compiler, node) {
     }
 
     // empty expression, we're done.
-    if (isSimple) {
-        this.isSimple = true
+    if (isEmpty) {
+        this.isEmpty = true
         return
     }
 

+ 1 - 1
src/directives/with.js

@@ -3,7 +3,7 @@ var ViewModel
 module.exports = {
 
     bind: function () {
-        if (this.isSimple) {
+        if (this.isEmpty) {
             this.build()
         }
     },

+ 1 - 1
test/unit/specs/directive.js

@@ -102,7 +102,7 @@ describe('UNIT: Directive', function () {
         it('should return a simple Directive if expression is empty', function () {
             var d = Directive.parse('text', '', compiler)
             assert.ok(d instanceof Directive)
-            assert.ok(d.isSimple)
+            assert.ok(d.isEmpty)
         })
 
         it('should return an instance of Directive if args are good', function () {