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
*/
@@ -2046,6 +2046,24 @@ var transition = Object.freeze({
2046
2046
2047
2047
var arrayKeys = Object . getOwnPropertyNames ( arrayMethods ) ;
2048
2048
2049
+ /**
2050
+ * By default, when a reactive property is set, the new value is
2051
+ * also converted to become reactive. However in certain cases, e.g.
2052
+ * v-for scope alias and props, we don't want to force conversion
2053
+ * because the value may be a nested value under a frozen data structure.
2054
+ *
2055
+ * So whenever we want to set a reactive property without forcing
2056
+ * conversion on the new value, we wrap that call inside this function.
2057
+ */
2058
+
2059
+ var shouldConvert = true ;
2060
+
2061
+ function withoutConversion ( fn ) {
2062
+ shouldConvert = false ;
2063
+ fn ( ) ;
2064
+ shouldConvert = true ;
2065
+ }
2066
+
2049
2067
/**
2050
2068
* Observer class that are attached to each observed
2051
2069
* object. Once attached, the observer converts target
@@ -2183,7 +2201,7 @@ var transition = Object.freeze({
2183
2201
var ob ;
2184
2202
if ( hasOwn ( value , '__ob__' ) && value . __ob__ instanceof Observer ) {
2185
2203
ob = value . __ob__ ;
2186
- } else if ( ( isArray ( value ) || isPlainObject ( value ) ) && Object . isExtensible ( value ) && ! value . _isVue ) {
2204
+ } else if ( shouldConvert && ( isArray ( value ) || isPlainObject ( value ) ) && Object . isExtensible ( value ) && ! value . _isVue ) {
2187
2205
ob = new Observer ( value ) ;
2188
2206
}
2189
2207
if ( ob && vm ) {
@@ -2198,10 +2216,9 @@ var transition = Object.freeze({
2198
2216
* @param {Object } obj
2199
2217
* @param {String } key
2200
2218
* @param {* } val
2201
- * @param {Boolean } doNotObserve
2202
2219
*/
2203
2220
2204
- function defineReactive ( obj , key , val , doNotObserve ) {
2221
+ function defineReactive ( obj , key , val ) {
2205
2222
var dep = new Dep ( ) ;
2206
2223
2207
2224
var property = Object . getOwnPropertyDescriptor ( obj , key ) ;
@@ -2213,11 +2230,7 @@ var transition = Object.freeze({
2213
2230
var getter = property && property . get ;
2214
2231
var setter = property && property . set ;
2215
2232
2216
- // if doNotObserve is true, only use the child value observer
2217
- // if it already exists, and do not attempt to create it.
2218
- // this allows freezing a large object from the root and
2219
- // avoid unnecessary observation inside v-for fragments.
2220
- var childOb = doNotObserve ? isObject ( val ) && val . __ob__ : observe ( val ) ;
2233
+ var childOb = observe ( val ) ;
2221
2234
Object . defineProperty ( obj , key , {
2222
2235
enumerable : true ,
2223
2236
configurable : true ,
@@ -2247,7 +2260,7 @@ var transition = Object.freeze({
2247
2260
} else {
2248
2261
val = newVal ;
2249
2262
}
2250
- childOb = doNotObserve ? isObject ( newVal ) && newVal . __ob__ : observe ( newVal ) ;
2263
+ childOb = observe ( newVal ) ;
2251
2264
dep . notify ( ) ;
2252
2265
}
2253
2266
} ) ;
@@ -4021,7 +4034,9 @@ var template = Object.freeze({
4021
4034
// update data for track-by, object repeat &
4022
4035
// primitive values.
4023
4036
if ( trackByKey || convertedFromObject || primitive ) {
4024
- frag . scope [ alias ] = value ;
4037
+ withoutConversion ( function ( ) {
4038
+ frag . scope [ alias ] = value ;
4039
+ } ) ;
4025
4040
}
4026
4041
} else {
4027
4042
// new isntance
@@ -4111,7 +4126,11 @@ var template = Object.freeze({
4111
4126
// for two-way binding on alias
4112
4127
scope . $forContext = this ;
4113
4128
// define scope properties
4114
- defineReactive ( scope , alias , value , true /* do not observe */ ) ;
4129
+ // important: define the scope alias without forced conversion
4130
+ // so that frozen data structures remain non-reactive.
4131
+ withoutConversion ( function ( ) {
4132
+ defineReactive ( scope , alias , value ) ;
4133
+ } ) ;
4115
4134
defineReactive ( scope , '$index' , index ) ;
4116
4135
if ( key ) {
4117
4136
defineReactive ( scope , '$key' , key ) ;
@@ -5709,7 +5728,9 @@ var template = Object.freeze({
5709
5728
5710
5729
unbuild : function unbuild ( defer ) {
5711
5730
if ( this . waitingFor ) {
5712
- this . waitingFor . $destroy ( ) ;
5731
+ if ( ! this . keepAlive ) {
5732
+ this . waitingFor . $destroy ( ) ;
5733
+ }
5713
5734
this . waitingFor = null ;
5714
5735
}
5715
5736
var child = this . childVM ;
@@ -6003,15 +6024,7 @@ var template = Object.freeze({
6003
6024
value = getPropDefaultValue ( vm , prop . options ) ;
6004
6025
}
6005
6026
if ( assertProp ( prop , value ) ) {
6006
- var doNotObserve =
6007
- // if the passed down prop was already converted, then
6008
- // subsequent sets should also be converted, because the user
6009
- // may mutate the prop binding in the child component (#2549)
6010
- ! ( value && value . __ob__ ) && (
6011
- // otherwise we can skip observation for props that are either
6012
- // literal or points to a simple path (non-derived values)
6013
- ! prop . dynamic || isSimplePath ( prop . raw ) ) ;
6014
- defineReactive ( vm , key , value , doNotObserve ) ;
6027
+ defineReactive ( vm , key , value ) ;
6015
6028
}
6016
6029
}
6017
6030
@@ -6130,11 +6143,18 @@ var template = Object.freeze({
6130
6143
var childKey = prop . path ;
6131
6144
var parentKey = prop . parentPath ;
6132
6145
var twoWay = prop . mode === bindingModes . TWO_WAY ;
6146
+ var isSimple = isSimplePath ( parentKey ) ;
6133
6147
6134
6148
var parentWatcher = this . parentWatcher = new Watcher ( parent , parentKey , function ( val ) {
6135
6149
val = coerceProp ( prop , val ) ;
6136
6150
if ( assertProp ( prop , val ) ) {
6137
- child [ childKey ] = val ;
6151
+ if ( isSimple ) {
6152
+ withoutConversion ( function ( ) {
6153
+ child [ childKey ] = val ;
6154
+ } ) ;
6155
+ } else {
6156
+ child [ childKey ] = val ;
6157
+ }
6138
6158
}
6139
6159
} , {
6140
6160
twoWay : twoWay ,
@@ -6145,7 +6165,14 @@ var template = Object.freeze({
6145
6165
} ) ;
6146
6166
6147
6167
// set the child initial value.
6148
- initProp ( child , prop , parentWatcher . value ) ;
6168
+ var value = parentWatcher . value ;
6169
+ if ( isSimple && value !== undefined ) {
6170
+ withoutConversion ( function ( ) {
6171
+ initProp ( child , prop , value ) ;
6172
+ } ) ;
6173
+ } else {
6174
+ initProp ( child , prop , value ) ;
6175
+ }
6149
6176
6150
6177
// setup two-way binding
6151
6178
if ( twoWay ) {
@@ -7143,15 +7170,17 @@ var template = Object.freeze({
7143
7170
}
7144
7171
}
7145
7172
7146
- var attr , name , value , matched , dirName , arg , def , termDef ;
7173
+ var attr , name , value , modifiers , matched , dirName , rawName , arg , def , termDef ;
7147
7174
for ( var i = 0 , j = attrs . length ; i < j ; i ++ ) {
7148
7175
attr = attrs [ i ] ;
7149
- if ( matched = attr . name . match ( dirAttrRE ) ) {
7176
+ modifiers = parseModifiers ( attr . name ) ;
7177
+ name = attr . name . replace ( modifierRE , '' ) ;
7178
+ if ( matched = name . match ( dirAttrRE ) ) {
7150
7179
def = resolveAsset ( options , 'directives' , matched [ 1 ] ) ;
7151
7180
if ( def && def . terminal ) {
7152
7181
if ( ! termDef || ( def . priority || DEFAULT_TERMINAL_PRIORITY ) > termDef . priority ) {
7153
7182
termDef = def ;
7154
- name = attr . name ;
7183
+ rawName = attr . name ;
7155
7184
value = attr . value ;
7156
7185
dirName = matched [ 1 ] ;
7157
7186
arg = matched [ 2 ] ;
@@ -7161,7 +7190,7 @@ var template = Object.freeze({
7161
7190
}
7162
7191
7163
7192
if ( termDef ) {
7164
- return makeTerminalNodeLinkFn ( el , dirName , value , options , termDef , name , arg ) ;
7193
+ return makeTerminalNodeLinkFn ( el , dirName , value , options , termDef , rawName , arg , modifiers ) ;
7165
7194
}
7166
7195
}
7167
7196
@@ -7179,28 +7208,24 @@ var template = Object.freeze({
7179
7208
* @param {String } value
7180
7209
* @param {Object } options
7181
7210
* @param {Object } def
7182
- * @param {String } [attrName ]
7211
+ * @param {String } [rawName ]
7183
7212
* @param {String } [arg]
7213
+ * @param {Object } [modifiers]
7184
7214
* @return {Function } terminalLinkFn
7185
7215
*/
7186
7216
7187
- function makeTerminalNodeLinkFn ( el , dirName , value , options , def , attrName , arg ) {
7217
+ function makeTerminalNodeLinkFn ( el , dirName , value , options , def , rawName , arg , modifiers ) {
7188
7218
var parsed = parseDirective ( value ) ;
7189
7219
var descriptor = {
7190
7220
name : dirName ,
7221
+ arg : arg ,
7191
7222
expression : parsed . expression ,
7192
7223
filters : parsed . filters ,
7193
7224
raw : value ,
7194
- rawName : attrName ,
7225
+ attr : rawName ,
7226
+ modifiers : modifiers ,
7195
7227
def : def
7196
7228
} ;
7197
- if ( attrName ) {
7198
- descriptor . rawName = attrName ;
7199
- descriptor . modifiers = parseModifiers ( attrName ) ;
7200
- }
7201
- if ( arg ) {
7202
- descriptor . arg = arg . replace ( modifierRE , '' ) ;
7203
- }
7204
7229
// check ref for v-for and router-view
7205
7230
if ( dirName === 'for' || dirName === 'router-view' ) {
7206
7231
descriptor . ref = findRef ( el ) ;
@@ -8130,7 +8155,7 @@ var template = Object.freeze({
8130
8155
var i = params . length ;
8131
8156
var key , val , mappedKey ;
8132
8157
while ( i -- ) {
8133
- key = params [ i ] ;
8158
+ key = hyphenate ( params [ i ] ) ;
8134
8159
mappedKey = camelize ( key ) ;
8135
8160
val = getBindAttr ( this . el , key ) ;
8136
8161
if ( val != null ) {
@@ -9778,7 +9803,7 @@ var template = Object.freeze({
9778
9803
9779
9804
installGlobalAPI ( Vue ) ;
9780
9805
9781
- Vue . version = '1.0.19 ' ;
9806
+ Vue . version = '1.0.20 ' ;
9782
9807
9783
9808
// devtools global hook
9784
9809
/* istanbul ignore next */
0 commit comments