Skip to content

Commit a33a52d

Browse files
committed
comments for v-style update
1 parent b8b31a0 commit a33a52d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/directives/style.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module.exports = {
1515
this.setProp(this.arg, value)
1616
} else {
1717
if (typeof value === 'object') {
18+
// cache object styles so that only changed props
19+
// are actually updated.
1820
if (!this.cache) this.cache = {}
1921
for (var prop in value) {
2022
this.setProp(prop, value[prop])
@@ -32,6 +34,7 @@ module.exports = {
3234

3335
setProp: function (prop, value) {
3436
prop = normalize(prop)
37+
if (!prop) return // unsupported prop
3538
// cast possible numbers/booleans into strings
3639
if (value != null) value += ''
3740
if (value) {
@@ -49,6 +52,16 @@ module.exports = {
4952

5053
}
5154

55+
/**
56+
* Normalize a CSS property name.
57+
* - cache result
58+
* - auto prefix
59+
* - camelCase -> dash-case
60+
*
61+
* @param {String} prop
62+
* @return {String}
63+
*/
64+
5265
function normalize (prop) {
5366
if (propCache[prop]) {
5467
return propCache[prop]
@@ -58,6 +71,14 @@ function normalize (prop) {
5871
return res
5972
}
6073

74+
/**
75+
* Auto detect the appropriate prefix for a CSS property.
76+
* https://gist.github.com/paulirish/523692
77+
*
78+
* @param {String} prop
79+
* @return {String}
80+
*/
81+
6182
function prefix (prop) {
6283
prop = prop.replace(camelRE, '$1-$2').toLowerCase()
6384
var camel = _.camelize(prop)

0 commit comments

Comments
 (0)