Skip to content

Commit

Permalink
clean up: class and style no longer need args
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Sep 4, 2015
1 parent e70f714 commit 7e405f0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 43 deletions.
1 change: 0 additions & 1 deletion src/compiler/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ function checkElementDirectives (el, options) {
*/

function checkComponent (el, options) {
// TODO handle literal/dynamic
var component = _.checkComponent(el, options)
if (component) {
var descriptor = {
Expand Down
2 changes: 0 additions & 2 deletions src/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ var expParser = require('./parsers/expression')
* @constructor
*/

// TODO: 1.0.0 cleanup the arguments

function Directive (descriptor, vm, el, host, scope, frag) {
this.vm = vm
this.el = el
Expand Down
23 changes: 7 additions & 16 deletions src/directives/internal/class.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,14 @@ var removeClass = _.removeClass
module.exports = {

update: function (value) {
if (this.arg) {
// single toggle
if (value) {
addClass(this.el, this.arg)
} else {
removeClass(this.el, this.arg)
}
if (value && typeof value === 'string') {
this.handleObject(stringToObject(value))
} else if (_.isPlainObject(value)) {
this.handleObject(value)
} else if (_.isArray(value)) {
this.handleArray(value)
} else {
if (value && typeof value === 'string') {
this.handleObject(stringToObject(value))
} else if (_.isPlainObject(value)) {
this.handleObject(value)
} else if (_.isArray(value)) {
this.handleArray(value)
} else {
this.cleanup()
}
this.cleanup()
}
},

Expand Down
22 changes: 7 additions & 15 deletions src/directives/internal/el.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,9 @@ module.exports = {

priority: 1500,

bind: function () {
var scope = this._scope || this.vm
var refs = scope.$$
var id = this.id = this.arg // bind-el ?
? scope.$eval(this.expression)
: this.expression

if (process.env.NODE_ENV !== 'production' && this.arg) {
_.log(
'You are using bind- syntax on "el", which is a special ' +
'attribute. It will be evaluated only once.'
)
}

update: function (id) {
this.id = id
var refs = (this._scope || this.vm).$$
if (refs.hasOwnProperty(id)) {
refs[id] = this.el
} else {
Expand All @@ -26,6 +15,9 @@ module.exports = {
},

unbind: function () {
(this._scope || this.vm).$$[this.id] = null
var refs = (this._scope || this.vm).$$
if (refs[this.id] !== this.el) {
refs[this.id] = null
}
}
}
12 changes: 3 additions & 9 deletions src/directives/internal/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,11 @@ var propCache = {}

module.exports = {

deep: true,

update: function (value) {
if (this.arg) {
this.setProp(this.arg, value)
if (typeof value === 'object') {
this.objectHandler(value)
} else {
if (typeof value === 'object') {
this.objectHandler(value)
} else {
this.el.style.cssText = value
}
this.el.style.cssText = value
}
},

Expand Down

0 comments on commit 7e405f0

Please sign in to comment.