Skip to content

Commit

Permalink
isSimple -> isEmpty
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 22, 2014
1 parent 61e4dd1 commit f8e31f3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}
Expand Down
8 changes: 4 additions & 4 deletions src/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/directives/with.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var ViewModel
module.exports = {

bind: function () {
if (this.isSimple) {
if (this.isEmpty) {
this.build()
}
},
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit f8e31f3

Please sign in to comment.