@@ -1054,28 +1054,6 @@ function del(obj, key) {
1054
1054
ob . dep . notify ( ) ;
1055
1055
}
1056
1056
1057
- function proxy ( vm , key ) {
1058
- if ( ! isReserved ( key ) ) {
1059
- Object . defineProperty ( vm , key , {
1060
- configurable : true ,
1061
- enumerable : true ,
1062
- get : function proxyGetter ( ) {
1063
- return vm . _data [ key ] ;
1064
- } ,
1065
- set : function proxySetter ( val ) {
1066
- vm . _data [ key ] = val ;
1067
- }
1068
- } ) ;
1069
- }
1070
- }
1071
-
1072
- // using Object type to avoid flow complaining
1073
- function unproxy ( vm , key ) {
1074
- if ( ! isReserved ( key ) ) {
1075
- delete vm [ key ] ;
1076
- }
1077
- }
1078
-
1079
1057
function initState ( vm ) {
1080
1058
vm . _watchers = [ ] ;
1081
1059
initProps ( vm ) ;
@@ -1222,11 +1200,11 @@ function stateMixin(Vue) {
1222
1200
dataDef . get = function ( ) {
1223
1201
return this . _data ;
1224
1202
} ;
1225
- dataDef . set = function ( newData ) {
1226
- if ( newData !== this . _data ) {
1227
- setData ( this , newData ) ;
1228
- }
1229
- } ;
1203
+ if ( process . env . NODE_ENV !== 'production' ) {
1204
+ dataDef . set = function ( newData ) {
1205
+ warn ( 'Avoid replacing instance root $data. ' + 'Use nested data properties instead.' , this ) ;
1206
+ } ;
1207
+ }
1230
1208
Object . defineProperty ( Vue . prototype , '$data' , dataDef ) ;
1231
1209
1232
1210
Vue . prototype . $watch = function ( expOrFn , cb , options ) {
@@ -1243,37 +1221,19 @@ function stateMixin(Vue) {
1243
1221
} ;
1244
1222
}
1245
1223
1246
- function setData ( vm , newData ) {
1247
- newData = newData || { } ;
1248
- var oldData = vm . _data ;
1249
- vm . _data = newData ;
1250
- var keys = void 0 ,
1251
- key = void 0 ,
1252
- i = void 0 ;
1253
- // unproxy keys not present in new data
1254
- keys = Object . keys ( oldData ) ;
1255
- i = keys . length ;
1256
- while ( i -- ) {
1257
- key = keys [ i ] ;
1258
- if ( ! ( key in newData ) ) {
1259
- unproxy ( vm , key ) ;
1260
- }
1261
- }
1262
- // proxy keys not already proxied,
1263
- // and trigger change for changed values
1264
- keys = Object . keys ( newData ) ;
1265
- i = keys . length ;
1266
- while ( i -- ) {
1267
- key = keys [ i ] ;
1268
- if ( ! hasOwn ( vm , key ) ) {
1269
- // new property
1270
- proxy ( vm , key ) ;
1271
- }
1224
+ function proxy ( vm , key ) {
1225
+ if ( ! isReserved ( key ) ) {
1226
+ Object . defineProperty ( vm , key , {
1227
+ configurable : true ,
1228
+ enumerable : true ,
1229
+ get : function proxyGetter ( ) {
1230
+ return vm . _data [ key ] ;
1231
+ } ,
1232
+ set : function proxySetter ( val ) {
1233
+ vm . _data [ key ] = val ;
1234
+ }
1235
+ } ) ;
1272
1236
}
1273
- oldData . __ob__ && oldData . __ob__ . vmCount -- ;
1274
- observe ( newData ) ;
1275
- newData . __ob__ && newData . __ob__ . vmCount ++ ;
1276
- vm . $forceUpdate ( ) ;
1277
1237
}
1278
1238
1279
1239
var VNode = function ( ) {
@@ -1593,7 +1553,10 @@ function createComponent(Ctor, data, parent, context, host, tag) {
1593
1553
data = data || { } ;
1594
1554
1595
1555
// merge component management hooks onto the placeholder node
1596
- mergeHooks ( data ) ;
1556
+ // only need to do this if this is not a functional component
1557
+ if ( ! Ctor . options . functional ) {
1558
+ mergeHooks ( data ) ;
1559
+ }
1597
1560
1598
1561
// extract props
1599
1562
var propsData = extractProps ( data , Ctor ) ;
@@ -1773,12 +1736,24 @@ function mergeHook$1(a, b) {
1773
1736
1774
1737
function renderElementWithChildren ( vnode , children ) {
1775
1738
if ( vnode ) {
1776
- if ( vnode . componentOptions ) {
1739
+ var componentOptions = vnode . componentOptions ;
1740
+ if ( componentOptions ) {
1777
1741
if ( process . env . NODE_ENV !== 'production' && children && typeof children !== 'function' ) {
1778
1742
warn ( 'A component\'s children should be a function that returns the ' + 'children array. This allows the component to track the children ' + 'dependencies and optimizes re-rendering.' ) ;
1779
1743
}
1780
- vnode . componentOptions . children = children ;
1744
+ var CtorOptions = componentOptions . Ctor . options ;
1745
+ // functional component
1746
+ if ( CtorOptions . functional ) {
1747
+ return CtorOptions . render . call ( null , componentOptions . parent . $createElement , // h
1748
+ componentOptions . propsData || { } , // props
1749
+ normalizeChildren ( children ) // children
1750
+ ) ;
1751
+ } else {
1752
+ // normal component
1753
+ componentOptions . children = children ;
1754
+ }
1781
1755
} else {
1756
+ // normal element
1782
1757
vnode . setChildren ( normalizeChildren ( children ) ) ;
1783
1758
}
1784
1759
}
@@ -1872,7 +1847,7 @@ function renderMixin(Vue) {
1872
1847
resolveSlots ( vm , _renderChildren ) ;
1873
1848
}
1874
1849
// render self
1875
- var vnode = render . call ( vm . _renderProxy ) ;
1850
+ var vnode = render . call ( vm . _renderProxy , vm . $createElement ) ;
1876
1851
// return empty vnode in case the render function errored out
1877
1852
if ( ! ( vnode instanceof VNode ) ) {
1878
1853
if ( process . env . NODE_ENV !== 'production' && Array . isArray ( vnode ) ) {
@@ -2296,7 +2271,8 @@ function normalizeComponents(options) {
2296
2271
var components = options . components ;
2297
2272
var def = void 0 ;
2298
2273
for ( var key in components ) {
2299
- if ( isBuiltInTag ( key ) || config . isReservedTag ( key ) ) {
2274
+ var lower = key . toLowerCase ( ) ;
2275
+ if ( isBuiltInTag ( lower ) || config . isReservedTag ( lower ) ) {
2300
2276
process . env . NODE_ENV !== 'production' && warn ( 'Do not use built-in or reserved HTML elements as component ' + 'id: ' + key ) ;
2301
2277
continue ;
2302
2278
}
@@ -2757,7 +2733,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
2757
2733
}
2758
2734
} ) ;
2759
2735
2760
- Vue . version = '2.0.0-alpha.4 ' ;
2736
+ Vue . version = '2.0.0-alpha.5 ' ;
2761
2737
2762
2738
// attributes that should be using props for binding
2763
2739
var mustUseProp = makeMap ( 'value,selected,checked,muted' ) ;
@@ -3416,7 +3392,13 @@ function applyDirectives(oldVnode, vnode, hook) {
3416
3392
3417
3393
var ref = {
3418
3394
create : function create ( _ , vnode ) {
3419
- registerRef ( vnode , false ) ;
3395
+ registerRef ( vnode ) ;
3396
+ } ,
3397
+ update : function update ( oldVnode , vnode ) {
3398
+ if ( oldVnode . data . ref !== vnode . data . ref ) {
3399
+ registerRef ( oldVnode , true ) ;
3400
+ registerRef ( vnode ) ;
3401
+ }
3420
3402
} ,
3421
3403
destroy : function destroy ( vnode ) {
3422
3404
registerRef ( vnode , true ) ;
0 commit comments