mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-05 05:27:59 +08:00
comments for v-style update
This commit is contained in:
parent
b8b31a0610
commit
a33a52d9e5
@ -15,6 +15,8 @@ module.exports = {
|
||||
this.setProp(this.arg, value)
|
||||
} else {
|
||||
if (typeof value === 'object') {
|
||||
// cache object styles so that only changed props
|
||||
// are actually updated.
|
||||
if (!this.cache) this.cache = {}
|
||||
for (var prop in value) {
|
||||
this.setProp(prop, value[prop])
|
||||
@ -32,6 +34,7 @@ module.exports = {
|
||||
|
||||
setProp: function (prop, value) {
|
||||
prop = normalize(prop)
|
||||
if (!prop) return // unsupported prop
|
||||
// cast possible numbers/booleans into strings
|
||||
if (value != null) value += ''
|
||||
if (value) {
|
||||
@ -49,6 +52,16 @@ module.exports = {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a CSS property name.
|
||||
* - cache result
|
||||
* - auto prefix
|
||||
* - camelCase -> dash-case
|
||||
*
|
||||
* @param {String} prop
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
function normalize (prop) {
|
||||
if (propCache[prop]) {
|
||||
return propCache[prop]
|
||||
@ -58,6 +71,14 @@ function normalize (prop) {
|
||||
return res
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto detect the appropriate prefix for a CSS property.
|
||||
* https://gist.github.com/paulirish/523692
|
||||
*
|
||||
* @param {String} prop
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
function prefix (prop) {
|
||||
prop = prop.replace(camelRE, '$1-$2').toLowerCase()
|
||||
var camel = _.camelize(prop)
|
||||
|
Loading…
Reference in New Issue
Block a user