Skip to content

Commit 97c1a81

Browse files
author
Evan You
committed
v-style set cssText when no arg is present
1 parent 276c126 commit 97c1a81

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/directives/style.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ function camelReplacer (m) {
88
module.exports = {
99

1010
bind: function () {
11-
var prop = this.arg,
12-
first = prop.charAt(0)
11+
var prop = this.arg
12+
if (!prop) return
13+
var first = prop.charAt(0)
1314
if (first === '$') {
1415
// properties that start with $ will be auto-prefixed
1516
prop = prop.slice(1)
@@ -23,13 +24,17 @@ module.exports = {
2324

2425
update: function (value) {
2526
var prop = this.prop
26-
this.el.style[prop] = value
27-
if (this.prefixed) {
28-
prop = prop.charAt(0).toUpperCase() + prop.slice(1)
29-
var i = prefixes.length
30-
while (i--) {
31-
this.el.style[prefixes[i] + prop] = value
27+
if (prop) {
28+
this.el.style[prop] = value
29+
if (this.prefixed) {
30+
prop = prop.charAt(0).toUpperCase() + prop.slice(1)
31+
var i = prefixes.length
32+
while (i--) {
33+
this.el.style[prefixes[i] + prop] = value
34+
}
3235
}
36+
} else {
37+
this.el.style.cssText = value
3338
}
3439
}
3540

test/unit/specs/directives.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,14 @@ describe('UNIT: Directives', function () {
730730
assert.strictEqual(d.el.style.msTransform, val)
731731
})
732732

733+
it('should set cssText if no arg', function () {
734+
var d = mockDirective('style')
735+
d.bind()
736+
var val = 'color:#fff'
737+
d.update(val)
738+
assert.strictEqual(d.el.style.color, 'rgb(255, 255, 255)')
739+
})
740+
733741
})
734742

735743
describe('cloak', function () {

0 commit comments

Comments
 (0)