@@ -103,9 +103,9 @@ var capitalize = cached(function (str) {
103103/**
104104 * Hyphenate a camelCase string.
105105 */
106- var hyphenateRE = / ( [ a - z \d ] ) ( [ A - Z ] ) / g;
106+ var hyphenateRE = / ( [ ^ - ] ) ( [ A - Z ] ) / g;
107107var hyphenate = cached ( function ( str ) {
108- return str . replace ( hyphenateRE , '$1-$2' ) . toLowerCase ( ) ;
108+ return str . replace ( hyphenateRE , '$1-$2' ) . replace ( hyphenateRE , '$1-$2' ) . toLowerCase ( ) ;
109109} ) ;
110110
111111/**
@@ -315,7 +315,7 @@ function def(obj, key, val, enumerable) {
315315/**
316316 * Parse simple path.
317317 */
318- var bailRE = / [ ^ \w \. ] / ;
318+ var bailRE = / [ ^ \w \. \$ ] / ;
319319function parsePath ( path ) {
320320 if ( bailRE . test ( path ) ) {
321321 return ;
@@ -653,7 +653,7 @@ var Watcher = function () {
653653 this . getter = parsePath ( expOrFn ) ;
654654 if ( ! this . getter ) {
655655 this . getter = function ( ) { } ;
656- process . env . NODE_ENV !== 'production' && warn ( 'Failed watching path: ' + expOrFn + 'Watcher only accepts simple dot-delimited paths. ' + 'For full control, use a function instead.' , vm ) ;
656+ process . env . NODE_ENV !== 'production' && warn ( 'Failed watching path: " ' + expOrFn + '" ' + 'Watcher only accepts simple dot-delimited paths. ' + 'For full control, use a function instead.' , vm ) ;
657657 }
658658 }
659659 this . value = this . lazy ? undefined : this . get ( ) ;
@@ -676,12 +676,12 @@ var Watcher = function () {
676676 } else {
677677 warn ( 'Error during component render' , this . vm ) ;
678678 }
679- /* istanbul ignore else */
680- if ( config . errorHandler ) {
681- config . errorHandler . call ( null , e , this . vm ) ;
682- } else {
683- throw e ;
684- }
679+ }
680+ /* istanbul ignore else */
681+ if ( config . errorHandler ) {
682+ config . errorHandler . call ( null , e , this . vm ) ;
683+ } else {
684+ throw e ;
685685 }
686686 // return old value when evaluation fails so the current UI is preserved
687687 // if the error was somehow handled by user
@@ -1120,13 +1120,13 @@ function initProps(vm) {
11201120 var key = keys [ i ] ;
11211121 /* istanbul ignore else */
11221122 if ( process . env . NODE_ENV !== 'production' ) {
1123- defineReactive ( vm , key , validateProp ( vm , key , propsData ) , function ( ) {
1123+ defineReactive ( vm , key , validateProp ( key , props , propsData , vm ) , function ( ) {
11241124 if ( vm . $parent && ! observerState . isSettingProps ) {
11251125 warn ( 'Avoid mutating a prop directly since the value will be ' + 'overwritten whenever the parent component re-renders. ' + 'Instead, use a data or computed property based on the prop\'s ' + ( 'value. Prop being mutated: "' + key + '"' ) , vm ) ;
11261126 }
11271127 } ) ;
11281128 } else {
1129- defineReactive ( vm , key , validateProp ( vm , key , propsData ) ) ;
1129+ defineReactive ( vm , key , validateProp ( key , props , propsData , vm ) ) ;
11301130 }
11311131 } ;
11321132
@@ -1337,7 +1337,9 @@ function normalizeChildren(children, ns) {
13371337 last . text += c . text ;
13381338 } else {
13391339 // inherit parent namespace
1340- if ( ns && c . tag ) c . ns = ns ;
1340+ if ( ns ) {
1341+ applyNS ( c , ns ) ;
1342+ }
13411343 res . push ( c ) ;
13421344 }
13431345 }
@@ -1350,6 +1352,17 @@ function createTextVNode(val) {
13501352 return new VNode ( undefined , undefined , undefined , String ( val ) ) ;
13511353}
13521354
1355+ function applyNS ( vnode , ns ) {
1356+ if ( vnode . tag && ! vnode . ns ) {
1357+ vnode . ns = ns ;
1358+ if ( vnode . children ) {
1359+ for ( var i = 0 , l = vnode . children . length ; i < l ; i ++ ) {
1360+ applyNS ( vnode . children [ i ] , ns ) ;
1361+ }
1362+ }
1363+ }
1364+ }
1365+
13531366function updateListeners ( on , oldOn , add , remove ) {
13541367 var name = void 0 ,
13551368 cur = void 0 ,
@@ -1474,15 +1487,9 @@ function lifecycleMixin(Vue) {
14741487 if ( vm . $el ) {
14751488 vm . $el . __vue__ = vm ;
14761489 }
1477- // update parent vnode element after patch
1478- var parentNode = vm . $options . _parentVnode ;
1479- if ( parentNode ) {
1480- parentNode . elm = vm . $el ;
1481- // update parent $el if the parent is HOC
1482- // this is necessary because child is updated after parent
1483- if ( vm . $parent && parentNode === vm . $parent . _vnode ) {
1484- vm . $parent . $el = vm . $el ;
1485- }
1490+ // if parent is an HOC, update its $el as well
1491+ if ( vm . $vnode && vm . $parent && vm . $vnode === vm . $parent . _vnode ) {
1492+ vm . $parent . $el = vm . $el ;
14861493 }
14871494 if ( vm . _isMounted ) {
14881495 callHook ( vm , 'updated' ) ;
@@ -1502,7 +1509,7 @@ function lifecycleMixin(Vue) {
15021509 var propKeys = vm . $options . _propKeys || [ ] ;
15031510 for ( var i = 0 ; i < propKeys . length ; i ++ ) {
15041511 var key = propKeys [ i ] ;
1505- vm [ key ] = validateProp ( vm , key , propsData ) ;
1512+ vm [ key ] = validateProp ( key , vm . $options . props , propsData , vm ) ;
15061513 }
15071514 observerState . shouldConvert = true ;
15081515 if ( process . env . NODE_ENV !== 'production' ) {
@@ -1580,9 +1587,9 @@ function callHook(vm, hook) {
15801587var hooks = { init : init , prepatch : prepatch , insert : insert , destroy : destroy } ;
15811588var hooksToMerge = Object . keys ( hooks ) ;
15821589
1583- function createComponent ( Ctor , data , parent , context , host , children , tag ) {
1590+ function createComponent ( Ctor , data , parent , context , host , _children , tag ) {
15841591 // ensure children is a thunk
1585- if ( process . env . NODE_ENV !== 'production' && children && typeof children !== 'function' ) {
1592+ if ( process . env . NODE_ENV !== 'production' && _children && typeof _children !== 'function' ) {
15861593 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.' ) ;
15871594 }
15881595
@@ -1627,10 +1634,22 @@ function createComponent(Ctor, data, parent, context, host, children, tag) {
16271634
16281635 // functional component
16291636 if ( Ctor . options . functional ) {
1630- return Ctor . options . render . call ( null , parent . $createElement , // h
1631- propsData || { } , // props
1632- normalizeChildren ( children ) // children
1633- ) ;
1637+ var _ret = function ( ) {
1638+ var props = { } ;
1639+ var propOptions = Ctor . options . props ;
1640+ if ( propOptions ) {
1641+ Object . keys ( propOptions ) . forEach ( function ( key ) {
1642+ props [ key ] = validateProp ( key , propOptions , propsData ) ;
1643+ } ) ;
1644+ }
1645+ return {
1646+ v : Ctor . options . render . call ( null , parent . $createElement , { props : props , parent : parent , data : data , children : function children ( ) {
1647+ return normalizeChildren ( _children ) ;
1648+ } } )
1649+ } ;
1650+ } ( ) ;
1651+
1652+ if ( typeof _ret === "object" ) return _ret . v ;
16341653 }
16351654
16361655 // merge component management hooks onto the placeholder node
@@ -1645,7 +1664,7 @@ function createComponent(Ctor, data, parent, context, host, children, tag) {
16451664
16461665 // return a placeholder vnode
16471666 var name = Ctor . options . name || tag ;
1648- var vnode = new VNode ( 'vue-component-' + Ctor . cid + ( name ? '-' + name : '' ) , data , undefined , undefined , undefined , undefined , context , host , { Ctor : Ctor , propsData : propsData , listeners : listeners , parent : parent , tag : tag , children : children } ) ;
1667+ var vnode = new VNode ( 'vue-component-' + Ctor . cid + ( name ? '-' + name : '' ) , data , undefined , undefined , undefined , undefined , context , host , { Ctor : Ctor , propsData : propsData , listeners : listeners , parent : parent , tag : tag , children : _children } ) ;
16491668 return vnode ;
16501669}
16511670
@@ -1714,7 +1733,7 @@ function resolveAsyncComponent(factory, cb) {
17141733 // pool callbacks
17151734 factory . pendingCallbacks . push ( cb ) ;
17161735 } else {
1717- var _ret = function ( ) {
1736+ var _ret2 = function ( ) {
17181737 factory . requested = true ;
17191738 var cbs = factory . pendingCallbacks = [ cb ] ;
17201739 var sync = true ;
@@ -1745,7 +1764,7 @@ function resolveAsyncComponent(factory, cb) {
17451764 } ;
17461765 } ( ) ;
17471766
1748- if ( typeof _ret === "object" ) return _ret . v ;
1767+ if ( typeof _ret2 === "object" ) return _ret2 . v ;
17491768 }
17501769}
17511770
@@ -1832,21 +1851,22 @@ function _createElement(tag, data, children) {
18321851 return emptyVNode ( ) ;
18331852 }
18341853 if ( typeof tag === 'string' ) {
1835- var namespace = config . getTagNamespace ( tag ) ;
18361854 var Ctor = void 0 ;
18371855 if ( config . isReservedTag ( tag ) ) {
1838- return new VNode ( tag , data , normalizeChildren ( children , namespace ) , undefined , undefined , namespace , context , host ) ;
1856+ // platform built-in elements
1857+ return new VNode ( tag , data , normalizeChildren ( children ) , undefined , undefined , undefined , context , host ) ;
18391858 } else if ( Ctor = resolveAsset ( context . $options , 'components' , tag ) ) {
1859+ // component
18401860 return createComponent ( Ctor , data , parent , context , host , children , tag ) ;
18411861 } else {
1842- if ( process . env . NODE_ENV !== 'production' ) {
1843- if ( ! namespace && ! ( config . ignoredElements && config . ignoredElements . indexOf ( tag ) > - 1 ) && config . isUnknownElement ( tag ) ) {
1844- warn ( 'Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.' ) ;
1845- }
1846- }
1847- return new VNode ( tag , data , normalizeChildren ( children , namespace ) , undefined , undefined , namespace , context , host ) ;
1862+ // unknown or namespaced elements
1863+ // check at runtime because it may get assigned a namespace when its
1864+ // parent normalizes children
1865+ var ns = config . getTagNamespace ( tag ) ;
1866+ return new VNode ( tag , data , normalizeChildren ( children , ns ) , undefined , undefined , ns , context , host ) ;
18481867 }
18491868 } else {
1869+ // direct component options / constructor
18501870 return createComponent ( tag , data , parent , context , host , children ) ;
18511871 }
18521872}
@@ -1856,7 +1876,8 @@ var renderState = {
18561876} ;
18571877
18581878function initRender ( vm ) {
1859- vm . _vnode = null ;
1879+ vm . $vnode = null ; // the placeholder node in parent tree
1880+ vm . _vnode = null ; // the root of the child tree
18601881 vm . _staticTrees = null ;
18611882 vm . $slots = { } ;
18621883 // bind the public createElement fn to this instance
@@ -1889,7 +1910,9 @@ function renderMixin(Vue) {
18891910 if ( staticRenderFns && ! this . _staticTrees ) {
18901911 this . _staticTrees = [ ] ;
18911912 }
1892-
1913+ // set parent vnode. this allows render functions to have access
1914+ // to the data on the placeholder node.
1915+ this . $vnode = _parentVnode ;
18931916 // resolve slots. becaues slots are rendered in parent scope,
18941917 // we set the activeInstance to parent.
18951918 if ( _renderChildren ) {
@@ -2443,10 +2466,10 @@ function resolveAsset(options, type, id, warnMissing) {
24432466 return res ;
24442467}
24452468
2446- function validateProp ( vm , key , propsData ) {
2469+ function validateProp ( key , propOptions , propsData , vm ) {
24472470 /* istanbul ignore if */
2448- if ( ! vm . $options . props || ! propsData ) return ;
2449- var prop = vm . $options . props [ key ] ;
2471+ if ( ! propsData ) return ;
2472+ var prop = propOptions [ key ] ;
24502473 var absent = ! hasOwn ( propsData , key ) ;
24512474 var value = propsData [ key ] ;
24522475 // handle boolean props
@@ -3074,7 +3097,6 @@ var bindRE = /^:|^v-bind:/;
30743097var onRE = / ^ @ | ^ v - o n : / ;
30753098var argRE = / : ( .* ) $ / ;
30763099var modifierRE = / \. [ ^ \. ] + / g;
3077- var camelRE = / [ a - z \d ] [ A - Z ] / ;
30783100
30793101var decodeHTMLCached = cached ( entities . decodeHTML ) ;
30803102
@@ -3108,14 +3130,6 @@ function parse(template, options) {
31083130 expectHTML : options . expectHTML ,
31093131 isUnaryTag : options . isUnaryTag ,
31103132 start : function start ( tag , attrs , unary ) {
3111- // check camelCase tag
3112- if ( camelRE . test ( tag ) ) {
3113- process . env . NODE_ENV !== 'production' && warn$1 ( 'Found camelCase tag in template: <' + tag + '>. ' + ( 'I\'ve converted it to <' + hyphenate ( tag ) + '> for you.' ) ) ;
3114- tag = hyphenate ( tag ) ;
3115- }
3116-
3117- tag = tag . toLowerCase ( ) ;
3118-
31193133 // check namespace.
31203134 // inherit parent ns if there is one
31213135 var ns = currentParent && currentParent . ns || platformGetTagNamespace ( tag ) ;
@@ -3679,7 +3693,7 @@ function genElement(el) {
36793693 code = transforms$1 [ i ] ( el , code ) ;
36803694 }
36813695 // check keep-alive
3682- if ( el . component && el . keepAlive ) {
3696+ if ( el . keepAlive ) {
36833697 code = '_h("KeepAlive",{props:{child:' + code + '}})' ;
36843698 }
36853699 return code ;
@@ -4079,13 +4093,14 @@ function genDefaultModel(el, value, modifiers) {
40794093
40804094 var event = lazy ? 'change' : 'input' ;
40814095 var needCompositionGuard = ! lazy && type !== 'range' ;
4096+ var isNative = el . tag === 'input' || el . tag === 'textarea' ;
40824097
4083- var valueExpression = '$event.target.value' + ( trim ? '.trim()' : '' ) ;
4098+ var valueExpression = isNative ? '$event.target.value' + ( trim ? '.trim()' : '' ) : '$event' ;
40844099 var code = number || type === 'number' ? value + '=_n(' + valueExpression + ')' : value + '=' + valueExpression ;
4085- if ( needCompositionGuard ) {
4100+ if ( isNative && needCompositionGuard ) {
40864101 code = 'if($event.target.composing)return;' + code ;
40874102 }
4088- addProp ( el , 'value' , '_s(' + value + ')' ) ;
4103+ addProp ( el , 'value' , isNative ? '_s(' + value + ')' : ' (' + value + ')' ) ;
40894104 addHandler ( el , event , code ) ;
40904105 if ( needCompositionGuard ) {
40914106 // need runtime directive code to help with composition events
0 commit comments