11/*!
2- * Vue.js v1.0.19
2+ * Vue.js v1.0.20
33 * (c) 2016 Evan You
44 * Released under the MIT License.
55 */
@@ -2042,6 +2042,24 @@ def(arrayProto, '$remove', function $remove(item) {
20422042
20432043var arrayKeys = Object . getOwnPropertyNames ( arrayMethods ) ;
20442044
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+
20452063/**
20462064 * Observer class that are attached to each observed
20472065 * object. Once attached, the observer converts target
@@ -2179,7 +2197,7 @@ function observe(value, vm) {
21792197 var ob ;
21802198 if ( hasOwn ( value , '__ob__' ) && value . __ob__ instanceof Observer ) {
21812199 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 ) {
21832201 ob = new Observer ( value ) ;
21842202 }
21852203 if ( ob && vm ) {
@@ -2194,10 +2212,9 @@ function observe(value, vm) {
21942212 * @param {Object } obj
21952213 * @param {String } key
21962214 * @param {* } val
2197- * @param {Boolean } doNotObserve
21982215 */
21992216
2200- function defineReactive ( obj , key , val , doNotObserve ) {
2217+ function defineReactive ( obj , key , val ) {
22012218 var dep = new Dep ( ) ;
22022219
22032220 var property = Object . getOwnPropertyDescriptor ( obj , key ) ;
@@ -2209,11 +2226,7 @@ function defineReactive(obj, key, val, doNotObserve) {
22092226 var getter = property && property . get ;
22102227 var setter = property && property . set ;
22112228
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 ) ;
22172230 Object . defineProperty ( obj , key , {
22182231 enumerable : true ,
22192232 configurable : true ,
@@ -2243,7 +2256,7 @@ function defineReactive(obj, key, val, doNotObserve) {
22432256 } else {
22442257 val = newVal ;
22452258 }
2246- childOb = doNotObserve ? isObject ( newVal ) && newVal . __ob__ : observe ( newVal ) ;
2259+ childOb = observe ( newVal ) ;
22472260 dep . notify ( ) ;
22482261 }
22492262 } ) ;
@@ -4017,7 +4030,9 @@ var vFor = {
40174030 // update data for track-by, object repeat &
40184031 // primitive values.
40194032 if ( trackByKey || convertedFromObject || primitive ) {
4020- frag . scope [ alias ] = value ;
4033+ withoutConversion ( function ( ) {
4034+ frag . scope [ alias ] = value ;
4035+ } ) ;
40214036 }
40224037 } else {
40234038 // new isntance
@@ -4107,7 +4122,11 @@ var vFor = {
41074122 // for two-way binding on alias
41084123 scope . $forContext = this ;
41094124 // 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+ } ) ;
41114130 defineReactive ( scope , '$index' , index ) ;
41124131 if ( key ) {
41134132 defineReactive ( scope , '$key' , key ) ;
@@ -5705,7 +5724,9 @@ var component = {
57055724
57065725 unbuild : function unbuild ( defer ) {
57075726 if ( this . waitingFor ) {
5708- this . waitingFor . $destroy ( ) ;
5727+ if ( ! this . keepAlive ) {
5728+ this . waitingFor . $destroy ( ) ;
5729+ }
57095730 this . waitingFor = null ;
57105731 }
57115732 var child = this . childVM ;
@@ -5999,15 +6020,7 @@ function initProp(vm, prop, value) {
59996020 value = getPropDefaultValue ( vm , prop . options ) ;
60006021 }
60016022 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 ) ;
60116024 }
60126025}
60136026
@@ -6126,11 +6139,18 @@ var propDef = {
61266139 var childKey = prop . path ;
61276140 var parentKey = prop . parentPath ;
61286141 var twoWay = prop . mode === bindingModes . TWO_WAY ;
6142+ var isSimple = isSimplePath ( parentKey ) ;
61296143
61306144 var parentWatcher = this . parentWatcher = new Watcher ( parent , parentKey , function ( val ) {
61316145 val = coerceProp ( prop , val ) ;
61326146 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+ }
61346154 }
61356155 } , {
61366156 twoWay : twoWay ,
@@ -6141,7 +6161,14 @@ var propDef = {
61416161 } ) ;
61426162
61436163 // 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+ }
61456172
61466173 // setup two-way binding
61476174 if ( twoWay ) {
@@ -7146,15 +7173,17 @@ function checkTerminalDirectives(el, attrs, options) {
71467173 }
71477174 }
71487175
7149- var attr , name , value , matched , dirName , arg , def , termDef ;
7176+ var attr , name , value , modifiers , matched , dirName , rawName , arg , def , termDef ;
71507177 for ( var i = 0 , j = attrs . length ; i < j ; i ++ ) {
71517178 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 ) ) {
71537182 def = resolveAsset ( options , 'directives' , matched [ 1 ] ) ;
71547183 if ( def && def . terminal ) {
71557184 if ( ! termDef || ( def . priority || DEFAULT_TERMINAL_PRIORITY ) > termDef . priority ) {
71567185 termDef = def ;
7157- name = attr . name ;
7186+ rawName = attr . name ;
71587187 value = attr . value ;
71597188 dirName = matched [ 1 ] ;
71607189 arg = matched [ 2 ] ;
@@ -7164,7 +7193,7 @@ function checkTerminalDirectives(el, attrs, options) {
71647193 }
71657194
71667195 if ( termDef ) {
7167- return makeTerminalNodeLinkFn ( el , dirName , value , options , termDef , name , arg ) ;
7196+ return makeTerminalNodeLinkFn ( el , dirName , value , options , termDef , rawName , arg , modifiers ) ;
71687197 }
71697198}
71707199
@@ -7182,28 +7211,24 @@ skip.terminal = true;
71827211 * @param {String } value
71837212 * @param {Object } options
71847213 * @param {Object } def
7185- * @param {String } [attrName ]
7214+ * @param {String } [rawName ]
71867215 * @param {String } [arg]
7216+ * @param {Object } [modifiers]
71877217 * @return {Function } terminalLinkFn
71887218 */
71897219
7190- function makeTerminalNodeLinkFn ( el , dirName , value , options , def , attrName , arg ) {
7220+ function makeTerminalNodeLinkFn ( el , dirName , value , options , def , rawName , arg , modifiers ) {
71917221 var parsed = parseDirective ( value ) ;
71927222 var descriptor = {
71937223 name : dirName ,
7224+ arg : arg ,
71947225 expression : parsed . expression ,
71957226 filters : parsed . filters ,
71967227 raw : value ,
7197- rawName : attrName ,
7228+ attr : rawName ,
7229+ modifiers : modifiers ,
71987230 def : def
71997231 } ;
7200- if ( attrName ) {
7201- descriptor . rawName = attrName ;
7202- descriptor . modifiers = parseModifiers ( attrName ) ;
7203- }
7204- if ( arg ) {
7205- descriptor . arg = arg . replace ( modifierRE , '' ) ;
7206- }
72077232 // check ref for v-for and router-view
72087233 if ( dirName === 'for' || dirName === 'router-view' ) {
72097234 descriptor . ref = findRef ( el ) ;
@@ -8133,7 +8158,7 @@ Directive.prototype._setupParams = function () {
81338158 var i = params . length ;
81348159 var key , val , mappedKey ;
81358160 while ( i -- ) {
8136- key = params [ i ] ;
8161+ key = hyphenate ( params [ i ] ) ;
81378162 mappedKey = camelize ( key ) ;
81388163 val = getBindAttr ( this . el , key ) ;
81398164 if ( val != null ) {
@@ -9781,7 +9806,7 @@ function installGlobalAPI (Vue) {
97819806
97829807installGlobalAPI ( Vue ) ;
97839808
9784- Vue . version = '1.0.19 ' ;
9809+ Vue . version = '1.0.20 ' ;
97859810
97869811// devtools global hook
97879812/* istanbul ignore next */
0 commit comments