1
1
/*!
2
- * Vue.js v1.0.19
2
+ * Vue.js v1.0.20
3
3
* (c) 2016 Evan You
4
4
* Released under the MIT License.
5
5
*/
@@ -2042,6 +2042,24 @@ def(arrayProto, '$remove', function $remove(item) {
2042
2042
2043
2043
var arrayKeys = Object . getOwnPropertyNames ( arrayMethods ) ;
2044
2044
2045
+ /**
2046
+ * By default, when a reactive property is set, the new value is
2047
+ * also converted to become reactive. However in certain cases, e.g.
2048
+ * v-for scope alias and props, we don't want to force conversion
2049
+ * because the value may be a nested value under a frozen data structure.
2050
+ *
2051
+ * So whenever we want to set a reactive property without forcing
2052
+ * conversion on the new value, we wrap that call inside this function.
2053
+ */
2054
+
2055
+ var shouldConvert = true ;
2056
+
2057
+ function withoutConversion ( fn ) {
2058
+ shouldConvert = false ;
2059
+ fn ( ) ;
2060
+ shouldConvert = true ;
2061
+ }
2062
+
2045
2063
/**
2046
2064
* Observer class that are attached to each observed
2047
2065
* object. Once attached, the observer converts target
@@ -2179,7 +2197,7 @@ function observe(value, vm) {
2179
2197
var ob ;
2180
2198
if ( hasOwn ( value , '__ob__' ) && value . __ob__ instanceof Observer ) {
2181
2199
ob = value . __ob__ ;
2182
- } else if ( ( isArray ( value ) || isPlainObject ( value ) ) && Object . isExtensible ( value ) && ! value . _isVue ) {
2200
+ } else if ( shouldConvert && ( isArray ( value ) || isPlainObject ( value ) ) && Object . isExtensible ( value ) && ! value . _isVue ) {
2183
2201
ob = new Observer ( value ) ;
2184
2202
}
2185
2203
if ( ob && vm ) {
@@ -2194,10 +2212,9 @@ function observe(value, vm) {
2194
2212
* @param {Object } obj
2195
2213
* @param {String } key
2196
2214
* @param {* } val
2197
- * @param {Boolean } doNotObserve
2198
2215
*/
2199
2216
2200
- function defineReactive ( obj , key , val , doNotObserve ) {
2217
+ function defineReactive ( obj , key , val ) {
2201
2218
var dep = new Dep ( ) ;
2202
2219
2203
2220
var property = Object . getOwnPropertyDescriptor ( obj , key ) ;
@@ -2209,11 +2226,7 @@ function defineReactive(obj, key, val, doNotObserve) {
2209
2226
var getter = property && property . get ;
2210
2227
var setter = property && property . set ;
2211
2228
2212
- // if doNotObserve is true, only use the child value observer
2213
- // if it already exists, and do not attempt to create it.
2214
- // this allows freezing a large object from the root and
2215
- // avoid unnecessary observation inside v-for fragments.
2216
- var childOb = doNotObserve ? isObject ( val ) && val . __ob__ : observe ( val ) ;
2229
+ var childOb = observe ( val ) ;
2217
2230
Object . defineProperty ( obj , key , {
2218
2231
enumerable : true ,
2219
2232
configurable : true ,
@@ -2243,7 +2256,7 @@ function defineReactive(obj, key, val, doNotObserve) {
2243
2256
} else {
2244
2257
val = newVal ;
2245
2258
}
2246
- childOb = doNotObserve ? isObject ( newVal ) && newVal . __ob__ : observe ( newVal ) ;
2259
+ childOb = observe ( newVal ) ;
2247
2260
dep . notify ( ) ;
2248
2261
}
2249
2262
} ) ;
@@ -4017,7 +4030,9 @@ var vFor = {
4017
4030
// update data for track-by, object repeat &
4018
4031
// primitive values.
4019
4032
if ( trackByKey || convertedFromObject || primitive ) {
4020
- frag . scope [ alias ] = value ;
4033
+ withoutConversion ( function ( ) {
4034
+ frag . scope [ alias ] = value ;
4035
+ } ) ;
4021
4036
}
4022
4037
} else {
4023
4038
// new isntance
@@ -4107,7 +4122,11 @@ var vFor = {
4107
4122
// for two-way binding on alias
4108
4123
scope . $forContext = this ;
4109
4124
// define scope properties
4110
- defineReactive ( scope , alias , value , true /* do not observe */ ) ;
4125
+ // important: define the scope alias without forced conversion
4126
+ // so that frozen data structures remain non-reactive.
4127
+ withoutConversion ( function ( ) {
4128
+ defineReactive ( scope , alias , value ) ;
4129
+ } ) ;
4111
4130
defineReactive ( scope , '$index' , index ) ;
4112
4131
if ( key ) {
4113
4132
defineReactive ( scope , '$key' , key ) ;
@@ -5705,7 +5724,9 @@ var component = {
5705
5724
5706
5725
unbuild : function unbuild ( defer ) {
5707
5726
if ( this . waitingFor ) {
5708
- this . waitingFor . $destroy ( ) ;
5727
+ if ( ! this . keepAlive ) {
5728
+ this . waitingFor . $destroy ( ) ;
5729
+ }
5709
5730
this . waitingFor = null ;
5710
5731
}
5711
5732
var child = this . childVM ;
@@ -5999,15 +6020,7 @@ function initProp(vm, prop, value) {
5999
6020
value = getPropDefaultValue ( vm , prop . options ) ;
6000
6021
}
6001
6022
if ( assertProp ( prop , value ) ) {
6002
- var doNotObserve =
6003
- // if the passed down prop was already converted, then
6004
- // subsequent sets should also be converted, because the user
6005
- // may mutate the prop binding in the child component (#2549)
6006
- ! ( value && value . __ob__ ) && (
6007
- // otherwise we can skip observation for props that are either
6008
- // literal or points to a simple path (non-derived values)
6009
- ! prop . dynamic || isSimplePath ( prop . raw ) ) ;
6010
- defineReactive ( vm , key , value , doNotObserve ) ;
6023
+ defineReactive ( vm , key , value ) ;
6011
6024
}
6012
6025
}
6013
6026
@@ -6126,11 +6139,18 @@ var propDef = {
6126
6139
var childKey = prop . path ;
6127
6140
var parentKey = prop . parentPath ;
6128
6141
var twoWay = prop . mode === bindingModes . TWO_WAY ;
6142
+ var isSimple = isSimplePath ( parentKey ) ;
6129
6143
6130
6144
var parentWatcher = this . parentWatcher = new Watcher ( parent , parentKey , function ( val ) {
6131
6145
val = coerceProp ( prop , val ) ;
6132
6146
if ( assertProp ( prop , val ) ) {
6133
- child [ childKey ] = val ;
6147
+ if ( isSimple ) {
6148
+ withoutConversion ( function ( ) {
6149
+ child [ childKey ] = val ;
6150
+ } ) ;
6151
+ } else {
6152
+ child [ childKey ] = val ;
6153
+ }
6134
6154
}
6135
6155
} , {
6136
6156
twoWay : twoWay ,
@@ -6141,7 +6161,14 @@ var propDef = {
6141
6161
} ) ;
6142
6162
6143
6163
// set the child initial value.
6144
- initProp ( child , prop , parentWatcher . value ) ;
6164
+ var value = parentWatcher . value ;
6165
+ if ( isSimple && value !== undefined ) {
6166
+ withoutConversion ( function ( ) {
6167
+ initProp ( child , prop , value ) ;
6168
+ } ) ;
6169
+ } else {
6170
+ initProp ( child , prop , value ) ;
6171
+ }
6145
6172
6146
6173
// setup two-way binding
6147
6174
if ( twoWay ) {
@@ -7146,15 +7173,17 @@ function checkTerminalDirectives(el, attrs, options) {
7146
7173
}
7147
7174
}
7148
7175
7149
- var attr , name , value , matched , dirName , arg , def , termDef ;
7176
+ var attr , name , value , modifiers , matched , dirName , rawName , arg , def , termDef ;
7150
7177
for ( var i = 0 , j = attrs . length ; i < j ; i ++ ) {
7151
7178
attr = attrs [ i ] ;
7152
- if ( matched = attr . name . match ( dirAttrRE ) ) {
7179
+ modifiers = parseModifiers ( attr . name ) ;
7180
+ name = attr . name . replace ( modifierRE , '' ) ;
7181
+ if ( matched = name . match ( dirAttrRE ) ) {
7153
7182
def = resolveAsset ( options , 'directives' , matched [ 1 ] ) ;
7154
7183
if ( def && def . terminal ) {
7155
7184
if ( ! termDef || ( def . priority || DEFAULT_TERMINAL_PRIORITY ) > termDef . priority ) {
7156
7185
termDef = def ;
7157
- name = attr . name ;
7186
+ rawName = attr . name ;
7158
7187
value = attr . value ;
7159
7188
dirName = matched [ 1 ] ;
7160
7189
arg = matched [ 2 ] ;
@@ -7164,7 +7193,7 @@ function checkTerminalDirectives(el, attrs, options) {
7164
7193
}
7165
7194
7166
7195
if ( termDef ) {
7167
- return makeTerminalNodeLinkFn ( el , dirName , value , options , termDef , name , arg ) ;
7196
+ return makeTerminalNodeLinkFn ( el , dirName , value , options , termDef , rawName , arg , modifiers ) ;
7168
7197
}
7169
7198
}
7170
7199
@@ -7182,28 +7211,24 @@ skip.terminal = true;
7182
7211
* @param {String } value
7183
7212
* @param {Object } options
7184
7213
* @param {Object } def
7185
- * @param {String } [attrName ]
7214
+ * @param {String } [rawName ]
7186
7215
* @param {String } [arg]
7216
+ * @param {Object } [modifiers]
7187
7217
* @return {Function } terminalLinkFn
7188
7218
*/
7189
7219
7190
- function makeTerminalNodeLinkFn ( el , dirName , value , options , def , attrName , arg ) {
7220
+ function makeTerminalNodeLinkFn ( el , dirName , value , options , def , rawName , arg , modifiers ) {
7191
7221
var parsed = parseDirective ( value ) ;
7192
7222
var descriptor = {
7193
7223
name : dirName ,
7224
+ arg : arg ,
7194
7225
expression : parsed . expression ,
7195
7226
filters : parsed . filters ,
7196
7227
raw : value ,
7197
- rawName : attrName ,
7228
+ attr : rawName ,
7229
+ modifiers : modifiers ,
7198
7230
def : def
7199
7231
} ;
7200
- if ( attrName ) {
7201
- descriptor . rawName = attrName ;
7202
- descriptor . modifiers = parseModifiers ( attrName ) ;
7203
- }
7204
- if ( arg ) {
7205
- descriptor . arg = arg . replace ( modifierRE , '' ) ;
7206
- }
7207
7232
// check ref for v-for and router-view
7208
7233
if ( dirName === 'for' || dirName === 'router-view' ) {
7209
7234
descriptor . ref = findRef ( el ) ;
@@ -8133,7 +8158,7 @@ Directive.prototype._setupParams = function () {
8133
8158
var i = params . length ;
8134
8159
var key , val , mappedKey ;
8135
8160
while ( i -- ) {
8136
- key = params [ i ] ;
8161
+ key = hyphenate ( params [ i ] ) ;
8137
8162
mappedKey = camelize ( key ) ;
8138
8163
val = getBindAttr ( this . el , key ) ;
8139
8164
if ( val != null ) {
@@ -9781,7 +9806,7 @@ function installGlobalAPI (Vue) {
9781
9806
9782
9807
installGlobalAPI ( Vue ) ;
9783
9808
9784
- Vue . version = '1.0.19 ' ;
9809
+ Vue . version = '1.0.20 ' ;
9785
9810
9786
9811
// devtools global hook
9787
9812
/* istanbul ignore next */
0 commit comments