Skip to content

Commit

Permalink
remove v-style and v-visible
Browse files Browse the repository at this point in the history
  • Loading branch information
Evan You committed Jan 6, 2014
1 parent 2e33033 commit 20def90
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 75 deletions.
23 changes: 0 additions & 23 deletions src/directives/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ module.exports = {
this.el.innerHTML = utils.toText(value)
},

visible: function (value) {
this.el.style.visibility = value ? '' : 'hidden'
},

show: function (value) {
var el = this.el,
target = value ? '' : 'none',
Expand All @@ -46,25 +42,6 @@ module.exports = {
this.lastVal = value
}
}
},

style: {
bind: function () {
this.arg = convertCSSProperty(this.arg)
},
update: function (value) {
this.el.style[this.arg] = value
}
}
}

/**
* convert hyphen style CSS property to Camel style
*/
var CONVERT_RE = /-(.)/g
function convertCSSProperty (prop) {
if (prop.charAt(0) === '-') prop = prop.slice(1)
return prop.replace(CONVERT_RE, function (m, char) {
return char.toUpperCase()
})
}
52 changes: 0 additions & 52 deletions test/unit/specs/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,6 @@ describe('UNIT: Directives', function () {

})

describe('style', function () {

var dir = mockDirective('style')

it('should convert the arg from dash style to camel case', function () {
dir.arg = 'font-family'
dir.bind()
assert.strictEqual(dir.arg, 'fontFamily')
dir.arg = '-webkit-transform'
dir.bind()
assert.strictEqual(dir.arg, 'webkitTransform')
})

it('should update the element style', function () {
dir.update('rotate(20deg)')
assert.strictEqual(dir.el.style.webkitTransform, 'rotate(20deg)')
})

})

describe('show', function () {

var dir = mockDirective('show')
Expand Down Expand Up @@ -130,38 +110,6 @@ describe('UNIT: Directives', function () {

})

describe('visible', function () {

var dir = mockDirective('visible')

it('should be default value when value is truthy', function () {
dir.update(1)
assert.strictEqual(dir.el.style.visibility, '')
dir.update('hi!')
assert.strictEqual(dir.el.style.visibility, '')
dir.update(true)
assert.strictEqual(dir.el.style.visibility, '')
dir.update({})
assert.strictEqual(dir.el.style.visibility, '')
dir.update(function () {})
assert.strictEqual(dir.el.style.visibility, '')
})

it('should be hidden when value is falsy', function () {
dir.update(0)
assert.strictEqual(dir.el.style.visibility, 'hidden')
dir.update('')
assert.strictEqual(dir.el.style.visibility, 'hidden')
dir.update(false)
assert.strictEqual(dir.el.style.visibility, 'hidden')
dir.update(null)
assert.strictEqual(dir.el.style.visibility, 'hidden')
dir.update(undefined)
assert.strictEqual(dir.el.style.visibility, 'hidden')
})

})

describe('class', function () {

it('should set class to the value if it has no arg', function () {
Expand Down

0 comments on commit 20def90

Please sign in to comment.