Skip to content

Commit

Permalink
enteredView/leftView -> attached/detached
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 13, 2014
1 parent 11e1a25 commit 7a4de5f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var Emitter = require('./emitter'),
hooks = [
'created', 'ready',
'beforeDestroy', 'afterDestroy',
'enteredView', 'leftView'
'attached', 'detached'
]

/**
Expand Down
2 changes: 1 addition & 1 deletion src/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var transition = module.exports = function (el, stage, cb, compiler) {

var changeState = function () {
cb()
compiler.execHook(stage > 0 ? 'enteredView' : 'leftView')
compiler.execHook(stage > 0 ? 'attached' : 'detached')
}

if (compiler.init) {
Expand Down
12 changes: 6 additions & 6 deletions test/unit/specs/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -788,17 +788,17 @@ describe('UNIT: API', function () {

})

describe('enteredView', function () {
describe('attached', function () {

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

})

describe('leftView', function () {
describe('detached', function () {

it('should be called after left view', function () {
var called1 = false, called2 = false,
test = new Vue({
leftView: function () {
detached: function () {
assert.strictEqual(this.$el.parentNode, null)
called1 = true
}
})
test.$on('hook:leftView', function () {
test.$on('hook:detached', function () {
called2 = true
})
document.getElementById('test').appendChild(test.$el)
Expand Down
28 changes: 14 additions & 14 deletions test/unit/specs/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('UNIT: Transition', function () {
var code = transition(null, 1, c.change, compiler)
assert.ok(c.called)
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 () {
Expand All @@ -25,7 +25,7 @@ describe('UNIT: Transition', function () {
code = transition(mockEl(), 1, c.change, compiler)
assert.ok(c.called)
assert.strictEqual(code, codes.SKIP)
assert.ok(compiler.enteredView)
assert.ok(compiler.attached)
})

})
Expand All @@ -40,7 +40,7 @@ describe('UNIT: Transition', function () {
code = transition(mockEl('css'), 1, c.change, compiler)
assert.ok(c.called)
assert.strictEqual(code, codes.CSS_SKIP)
assert.ok(compiler.enteredView)
assert.ok(compiler.attached)
})

// skip the rest
Expand Down Expand Up @@ -83,8 +83,8 @@ describe('UNIT: Transition', function () {
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)
})

})
Expand Down Expand Up @@ -125,8 +125,8 @@ describe('UNIT: Transition', function () {
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)
})

})
Expand All @@ -141,7 +141,7 @@ describe('UNIT: Transition', function () {
code = transition(mockEl('js'), 1, c.change, compiler)
assert.ok(c.called)
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 () {
Expand All @@ -150,14 +150,14 @@ describe('UNIT: Transition', function () {
code = transition(mockEl('js'), 1, c.change, compiler)
assert.ok(c.called)
assert.strictEqual(code, codes.JS_SKIP_E)
assert.ok(compiler.enteredView)
assert.ok(compiler.attached)

c = mockChange()
compiler = mockCompiler({})
code = transition(mockEl('js'), -1, c.change, compiler)
assert.ok(c.called)
assert.strictEqual(code, codes.JS_SKIP_L)
assert.ok(compiler.leftView)
assert.ok(compiler.detached)
})

describe('enter', function () {
Expand All @@ -182,8 +182,8 @@ describe('UNIT: Transition', function () {
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)
})

})
Expand All @@ -210,8 +210,8 @@ describe('UNIT: Transition', function () {
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)
})

})
Expand Down

0 comments on commit 7a4de5f

Please sign in to comment.