Kaynağa Gözat

enteredView/leftView -> attached/detached

Evan You 12 yıl önce
ebeveyn
işleme
7a4de5f2d3
4 değiştirilmiş dosya ile 22 ekleme ve 22 silme
  1. 1 1
      src/compiler.js
  2. 1 1
      src/transition.js
  3. 6 6
      test/unit/specs/api.js
  4. 14 14
      test/unit/specs/transition.js

+ 1 - 1
src/compiler.js

@@ -20,7 +20,7 @@ var Emitter     = require('./emitter'),
     hooks = [
     hooks = [
         'created', 'ready',
         'created', 'ready',
         'beforeDestroy', 'afterDestroy',
         'beforeDestroy', 'afterDestroy',
-        'enteredView', 'leftView'
+        'attached', 'detached'
     ]
     ]
 
 
 /**
 /**

+ 1 - 1
src/transition.js

@@ -23,7 +23,7 @@ var transition = module.exports = function (el, stage, cb, compiler) {
 
 
     var changeState = function () {
     var changeState = function () {
         cb()
         cb()
-        compiler.execHook(stage > 0 ? 'enteredView' : 'leftView')
+        compiler.execHook(stage > 0 ? 'attached' : 'detached')
     }
     }
 
 
     if (compiler.init) {
     if (compiler.init) {

+ 6 - 6
test/unit/specs/api.js

@@ -788,17 +788,17 @@ describe('UNIT: API', function () {
 
 
                 })
                 })
 
 
-                describe('enteredView', function () {
+                describe('attached', function () {
                     
                     
                     it('should be called after enter view', function () {
                     it('should be called after enter view', function () {
                         var called1 = false, called2 = false,
                         var called1 = false, called2 = false,
                             test = new Vue({
                             test = new Vue({
-                                enteredView: function () {
+                                attached: function () {
                                     assert.strictEqual(this.$el.parentNode, document.getElementById('test'))
                                     assert.strictEqual(this.$el.parentNode, document.getElementById('test'))
                                     called1 = true
                                     called1 = true
                                 }
                                 }
                             })
                             })
-                        test.$on('hook:enteredView', function () {
+                        test.$on('hook:attached', function () {
                             called2 = true
                             called2 = true
                         })
                         })
                         test.$appendTo('#test')
                         test.$appendTo('#test')
@@ -808,17 +808,17 @@ describe('UNIT: API', function () {
 
 
                 })
                 })
 
 
-                describe('leftView', function () {
+                describe('detached', function () {
                     
                     
                     it('should be called after left view', function () {
                     it('should be called after left view', function () {
                         var called1 = false, called2 = false,
                         var called1 = false, called2 = false,
                             test = new Vue({
                             test = new Vue({
-                                leftView: function () {
+                                detached: function () {
                                     assert.strictEqual(this.$el.parentNode, null)
                                     assert.strictEqual(this.$el.parentNode, null)
                                     called1 = true
                                     called1 = true
                                 }
                                 }
                             })
                             })
-                        test.$on('hook:leftView', function () {
+                        test.$on('hook:detached', function () {
                             called2 = true
                             called2 = true
                         })
                         })
                         document.getElementById('test').appendChild(test.$el)
                         document.getElementById('test').appendChild(test.$el)

+ 14 - 14
test/unit/specs/transition.js

@@ -16,7 +16,7 @@ describe('UNIT: Transition', function () {
             var code = transition(null, 1, c.change, compiler)
             var code = transition(null, 1, c.change, compiler)
             assert.ok(c.called)
             assert.ok(c.called)
             assert.strictEqual(code, codes.INIT)
             assert.strictEqual(code, codes.INIT)
-            assert.ok(compiler.enteredView)
+            assert.ok(compiler.attached)
         })
         })
 
 
         it('should skip if no transition is found on the node', function () {
         it('should skip if no transition is found on the node', function () {
@@ -25,7 +25,7 @@ describe('UNIT: Transition', function () {
                 code = transition(mockEl(), 1, c.change, compiler)
                 code = transition(mockEl(), 1, c.change, compiler)
             assert.ok(c.called)
             assert.ok(c.called)
             assert.strictEqual(code, codes.SKIP)
             assert.strictEqual(code, codes.SKIP)
-            assert.ok(compiler.enteredView)
+            assert.ok(compiler.attached)
         })
         })
 
 
     })
     })
@@ -40,7 +40,7 @@ describe('UNIT: Transition', function () {
                     code = transition(mockEl('css'), 1, c.change, compiler)
                     code = transition(mockEl('css'), 1, c.change, compiler)
                 assert.ok(c.called)
                 assert.ok(c.called)
                 assert.strictEqual(code, codes.CSS_SKIP)
                 assert.strictEqual(code, codes.CSS_SKIP)
-                assert.ok(compiler.enteredView)
+                assert.ok(compiler.attached)
             })
             })
 
 
             // skip the rest
             // skip the rest
@@ -83,8 +83,8 @@ describe('UNIT: Transition', function () {
                 assert.strictEqual(code, codes.CSS_E)
                 assert.strictEqual(code, codes.CSS_E)
             })
             })
 
 
-            it('should have called enteredView hook', function () {
-                assert.ok(compiler.enteredView)
+            it('should have called attached hook', function () {
+                assert.ok(compiler.attached)
             })
             })
 
 
         })
         })
@@ -125,8 +125,8 @@ describe('UNIT: Transition', function () {
                 assert.strictEqual(code, codes.CSS_L)
                 assert.strictEqual(code, codes.CSS_L)
             })
             })
 
 
-            it('should have called leftView hook', function () {
-                assert.ok(compiler.leftView)
+            it('should have called detached hook', function () {
+                assert.ok(compiler.detached)
             })
             })
 
 
         })
         })
@@ -141,7 +141,7 @@ describe('UNIT: Transition', function () {
                 code = transition(mockEl('js'), 1, c.change, compiler)
                 code = transition(mockEl('js'), 1, c.change, compiler)
             assert.ok(c.called)
             assert.ok(c.called)
             assert.strictEqual(code, codes.JS_SKIP)
             assert.strictEqual(code, codes.JS_SKIP)
-            assert.ok(compiler.enteredView)
+            assert.ok(compiler.attached)
         })
         })
 
 
         it('should skip if the option is given but the enter/leave func is not defined', function () {
         it('should skip if the option is given but the enter/leave func is not defined', function () {
@@ -150,14 +150,14 @@ describe('UNIT: Transition', function () {
                 code = transition(mockEl('js'), 1, c.change, compiler)
                 code = transition(mockEl('js'), 1, c.change, compiler)
             assert.ok(c.called)
             assert.ok(c.called)
             assert.strictEqual(code, codes.JS_SKIP_E)
             assert.strictEqual(code, codes.JS_SKIP_E)
-            assert.ok(compiler.enteredView)
+            assert.ok(compiler.attached)
 
 
             c = mockChange()
             c = mockChange()
             compiler = mockCompiler({})
             compiler = mockCompiler({})
             code = transition(mockEl('js'), -1, c.change, compiler)
             code = transition(mockEl('js'), -1, c.change, compiler)
             assert.ok(c.called)
             assert.ok(c.called)
             assert.strictEqual(code, codes.JS_SKIP_L)
             assert.strictEqual(code, codes.JS_SKIP_L)
-            assert.ok(compiler.leftView)
+            assert.ok(compiler.detached)
         })
         })
 
 
         describe('enter', function () {
         describe('enter', function () {
@@ -182,8 +182,8 @@ describe('UNIT: Transition', function () {
                 assert.strictEqual(code, codes.JS_E)
                 assert.strictEqual(code, codes.JS_E)
             })
             })
 
 
-            it('should have called enteredView hook', function () {
-                assert.ok(compiler.enteredView)
+            it('should have called attached hook', function () {
+                assert.ok(compiler.attached)
             })
             })
 
 
         })
         })
@@ -210,8 +210,8 @@ describe('UNIT: Transition', function () {
                 assert.strictEqual(code, codes.JS_L)
                 assert.strictEqual(code, codes.JS_L)
             })
             })
 
 
-            it('should have called leftView hook', function () {
-                assert.ok(compiler.leftView)
+            it('should have called detached hook', function () {
+                assert.ok(compiler.detached)
             })
             })
 
 
         })
         })