@@ -703,13 +703,8 @@ function resetSchedulerState() {
703703 */
704704function flushSchedulerQueue ( ) {
705705 flushing = true ;
706- runSchedulerQueue ( queue . sort ( queueSorter ) ) ;
707706 runSchedulerQueue ( userQueue ) ;
708- // user watchers triggered more watchers,
709- // keep flushing until it depletes
710- if ( queue . length ) {
711- return flushSchedulerQueue ( ) ;
712- }
707+ runSchedulerQueue ( queue . sort ( queueSorter ) ) ;
713708 // devtool hook
714709 /* istanbul ignore if */
715710 if ( devtools && config . devtools ) {
@@ -760,9 +755,14 @@ function runSchedulerQueue(queue) {
760755function queueWatcher ( watcher ) {
761756 var id = watcher . id ;
762757 if ( has [ id ] == null ) {
758+ // if already flushing, and all user watchers have already been run,
759+ // run the new user watcher immediately.
760+ if ( flushing && watcher . user && ! userQueue . length ) {
761+ return watcher . run ( ) ;
762+ }
763763 // push watcher into appropriate queue
764- var q = watcher . user ? userQueue : queue ;
765764 has [ id ] = true ;
765+ var q = watcher . user ? userQueue : queue ;
766766 if ( ! flushing ) {
767767 q . push ( watcher ) ;
768768 } else {
@@ -1565,8 +1565,8 @@ function initLifecycle(vm) {
15651565
15661566 // locate first non-abstract parent
15671567 var parent = options . parent ;
1568- if ( parent && ! options . _abstract ) {
1569- while ( parent . $options . _abstract && parent . $parent ) {
1568+ if ( parent && ! options . abstract ) {
1569+ while ( parent . $options . abstract && parent . $parent ) {
15701570 parent = parent . $parent ;
15711571 }
15721572 parent . $children . push ( vm ) ;
@@ -1693,7 +1693,7 @@ function lifecycleMixin(Vue) {
16931693 vm . _isBeingDestroyed = true ;
16941694 // remove self from parent
16951695 var parent = vm . $parent ;
1696- if ( parent && ! parent . _isBeingDestroyed && ! vm . $options . _abstract ) {
1696+ if ( parent && ! parent . _isBeingDestroyed && ! vm . $options . abstract ) {
16971697 remove ( parent . $children , vm ) ;
16981698 }
16991699 // teardown watchers
@@ -1791,9 +1791,17 @@ function createComponent(Ctor, data, parent, context, host, _children, tag) {
17911791 } ) ;
17921792 }
17931793 return {
1794- v : Ctor . options . render . call ( null , parent . $createElement , { props : props , parent : parent , data : data , children : function children ( ) {
1794+ v : Ctor . options . render . call ( null , parent . $createElement , {
1795+ props : props ,
1796+ parent : parent ,
1797+ data : data ,
1798+ children : function children ( ) {
17951799 return normalizeChildren ( _children ) ;
1796- } } )
1800+ } ,
1801+ slots : function slots ( ) {
1802+ return resolveSlots ( _children ) ;
1803+ }
1804+ } )
17971805 } ;
17981806 } ( ) ;
17991807
@@ -1806,9 +1814,8 @@ function createComponent(Ctor, data, parent, context, host, _children, tag) {
18061814 // extract listeners, since these needs to be treated as
18071815 // child component listeners instead of DOM listeners
18081816 var listeners = data . on ;
1809- if ( listeners ) {
1810- delete data . on ;
1811- }
1817+ // replace with listeners with .native modifier
1818+ data . on = data . nativeOn ;
18121819
18131820 // return a placeholder vnode
18141821 var name = Ctor . options . name || tag ;
@@ -1846,12 +1853,16 @@ function init(vnode, hydrating) {
18461853
18471854function prepatch ( oldVnode , vnode ) {
18481855 var options = vnode . componentOptions ;
1849- vnode . child = oldVnode . child ;
1850- vnode . child . _updateFromParent ( options . propsData , // updated props
1856+ var child = vnode . child = oldVnode . child ;
1857+ child . _updateFromParent ( options . propsData , // updated props
18511858 options . listeners , // updated listeners
18521859 vnode , // new parent vnode
18531860 options . children // new children
18541861 ) ;
1862+ // always update abstract components.
1863+ if ( child . $options . abstract ) {
1864+ child . $forceUpdate ( ) ;
1865+ }
18551866}
18561867
18571868function insert ( vnode ) {
@@ -1927,26 +1938,31 @@ function extractProps(data, Ctor) {
19271938 var res = { } ;
19281939 var attrs = data . attrs ;
19291940 var props = data . props ;
1941+ var domProps = data . domProps ;
19301942 var staticAttrs = data . staticAttrs ;
1931- if ( ! attrs && ! props && ! staticAttrs ) {
1932- return res ;
1933- }
1934- for ( var key in propOptions ) {
1935- var altKey = hyphenate ( key ) ;
1936- checkProp ( res , attrs , key , altKey ) || checkProp ( res , props , key , altKey ) || checkProp ( res , staticAttrs , key , altKey ) ;
1943+
1944+ if ( attrs || props || domProps || staticAttrs ) {
1945+ for ( var key in propOptions ) {
1946+ var altKey = hyphenate ( key ) ;
1947+ checkProp ( res , props , key , altKey , true ) || checkProp ( res , attrs , key , altKey ) || checkProp ( res , domProps , key , altKey ) || checkProp ( res , staticAttrs , key , altKey ) ;
1948+ }
19371949 }
19381950 return res ;
19391951}
19401952
1941- function checkProp ( res , hash , key , altKey ) {
1953+ function checkProp ( res , hash , key , altKey , preserve ) {
19421954 if ( hash ) {
19431955 if ( hasOwn ( hash , key ) ) {
19441956 res [ key ] = hash [ key ] ;
1945- delete hash [ key ] ;
1957+ if ( ! preserve ) {
1958+ delete hash [ key ] ;
1959+ }
19461960 return true ;
19471961 } else if ( hasOwn ( hash , altKey ) ) {
19481962 res [ key ] = hash [ altKey ] ;
1949- delete hash [ altKey ] ;
1963+ if ( ! preserve ) {
1964+ delete hash [ altKey ] ;
1965+ }
19501966 return true ;
19511967 }
19521968 }
@@ -2065,9 +2081,7 @@ function renderMixin(Vue) {
20652081 vm . $vnode = _parentVnode ;
20662082 // resolve slots. becaues slots are rendered in parent scope,
20672083 // we set the activeInstance to parent.
2068- if ( _renderChildren ) {
2069- resolveSlots ( vm , _renderChildren ) ;
2070- }
2084+ vm . $slots = resolveSlots ( _renderChildren ) ;
20712085 // render self
20722086 var vnode = void 0 ;
20732087 try {
@@ -2154,7 +2168,7 @@ function renderMixin(Vue) {
21542168 } ;
21552169
21562170 // apply v-bind object
2157- Vue . prototype . _b = function bindProps ( vnode , value ) {
2171+ Vue . prototype . _b = function bindProps ( vnode , value , asProp ) {
21582172 if ( value ) {
21592173 if ( ! isObject ( value ) ) {
21602174 process . env . NODE_ENV !== 'production' && warn ( 'v-bind without argument expects an Object or Array value' , this ) ;
@@ -2164,7 +2178,7 @@ function renderMixin(Vue) {
21642178 }
21652179 var data = vnode . data ;
21662180 for ( var key in value ) {
2167- var hash = config . mustUseProp ( key ) ? data . props || ( data . props = { } ) : data . attrs || ( data . attrs = { } ) ;
2181+ var hash = asProp || config . mustUseProp ( key ) ? data . domProps || ( data . domProps = { } ) : data . attrs || ( data . attrs = { } ) ;
21682182 hash [ key ] = value [ key ] ;
21692183 }
21702184 }
@@ -2177,8 +2191,11 @@ function renderMixin(Vue) {
21772191 } ;
21782192}
21792193
2180- function resolveSlots ( vm , renderChildren ) {
2181- var slots = vm . $slots = { } ;
2194+ function resolveSlots ( renderChildren ) {
2195+ var slots = { } ;
2196+ if ( ! renderChildren ) {
2197+ return slots ;
2198+ }
21822199 var children = normalizeChildren ( renderChildren ) || [ ] ;
21832200 var defaultSlot = [ ] ;
21842201 var name = void 0 ,
@@ -2201,6 +2218,7 @@ function resolveSlots(vm, renderChildren) {
22012218 if ( defaultSlot . length && ! ( defaultSlot . length === 1 && defaultSlot [ 0 ] . text === ' ' ) ) {
22022219 slots . default = defaultSlot ;
22032220 }
2221+ return slots ;
22042222}
22052223
22062224function initEvents ( vm ) {
@@ -3300,12 +3318,18 @@ function addHook(el, name, code) {
33003318}
33013319
33023320function addHandler ( el , name , value , modifiers ) {
3303- var events = el . events || ( el . events = { } ) ;
33043321 // check capture modifier
33053322 if ( modifiers && modifiers . capture ) {
33063323 delete modifiers . capture ;
33073324 name = '!' + name ; // mark the event as captured
33083325 }
3326+ var events = void 0 ;
3327+ if ( modifiers && modifiers . native ) {
3328+ delete modifiers . native ;
3329+ events = el . nativeEvents || ( el . nativeEvents = { } ) ;
3330+ } else {
3331+ events = el . events || ( el . events = { } ) ;
3332+ }
33093333 var newHandler = { value : value , modifiers : modifiers } ;
33103334 var handlers = events [ name ] ;
33113335 /* istanbul ignore if */
@@ -3358,9 +3382,7 @@ var decodeHTMLCached = cached(entities.decodeHTML);
33583382var warn$1 = void 0 ;
33593383var platformGetTagNamespace = void 0 ;
33603384var platformMustUseProp = void 0 ;
3361- var preTransforms = void 0 ;
33623385var transforms = void 0 ;
3363- var postTransforms = void 0 ;
33643386var delimiters = void 0 ;
33653387
33663388/**
@@ -3370,9 +3392,7 @@ function parse(template, options) {
33703392 warn$1 = options . warn || baseWarn ;
33713393 platformGetTagNamespace = options . getTagNamespace || no ;
33723394 platformMustUseProp = options . mustUseProp || no ;
3373- preTransforms = pluckModuleFunction ( options . modules , 'preTransformNode' ) ;
33743395 transforms = pluckModuleFunction ( options . modules , 'transformNode' ) ;
3375- postTransforms = pluckModuleFunction ( options . modules , 'postTransformNode' ) ;
33763396 delimiters = options . delimiters ;
33773397 var stack = [ ] ;
33783398 var preserveWhitespace = options . preserveWhitespace !== false ;
@@ -3411,11 +3431,6 @@ function parse(template, options) {
34113431 process . env . NODE_ENV !== 'production' && warn$1 ( 'Templates should only be responsbile for mapping the state to the ' + 'UI. Avoid placing tags with side-effects in your templates, such as ' + ( '<' + tag + '>.' ) ) ;
34123432 }
34133433
3414- // apply pre-transforms
3415- for ( var i = 0 ; i < preTransforms . length ; i ++ ) {
3416- preTransforms [ i ] ( element , options ) ;
3417- }
3418-
34193434 if ( ! inPre ) {
34203435 processPre ( element ) ;
34213436 if ( element . pre ) {
@@ -3437,8 +3452,8 @@ function parse(template, options) {
34373452 processRef ( element ) ;
34383453 processSlot ( element ) ;
34393454 processComponent ( element ) ;
3440- for ( var _i = 0 ; _i < transforms . length ; _i ++ ) {
3441- transforms [ _i ] ( element , options ) ;
3455+ for ( var i = 0 ; i < transforms . length ; i ++ ) {
3456+ transforms [ i ] ( element , options ) ;
34423457 }
34433458 processAttrs ( element ) ;
34443459 }
@@ -3471,10 +3486,6 @@ function parse(template, options) {
34713486 currentParent = element ;
34723487 stack . push ( element ) ;
34733488 }
3474- // apply post-transforms
3475- for ( var _i2 = 0 ; _i2 < postTransforms . length ; _i2 ++ ) {
3476- postTransforms [ _i2 ] ( element , options ) ;
3477- }
34783489 } ,
34793490 end : function end ( ) {
34803491 // remove trailing whitespace
@@ -3646,7 +3657,8 @@ function processAttrs(el) {
36463657 name = void 0 ,
36473658 value = void 0 ,
36483659 arg = void 0 ,
3649- modifiers = void 0 ;
3660+ modifiers = void 0 ,
3661+ isProp = void 0 ;
36503662 for ( i = 0 , l = list . length ; i < l ; i ++ ) {
36513663 name = list [ i ] . name ;
36523664 value = list [ i ] . value ;
@@ -3659,7 +3671,12 @@ function processAttrs(el) {
36593671 if ( bindRE . test ( name ) ) {
36603672 // v-bind
36613673 name = name . replace ( bindRE , '' ) ;
3662- if ( platformMustUseProp ( name ) ) {
3674+ if ( modifiers && modifiers . prop ) {
3675+ isProp = true ;
3676+ name = camelize ( name ) ;
3677+ if ( name === 'innerHtml' ) name = 'innerHTML' ;
3678+ }
3679+ if ( isProp || platformMustUseProp ( name ) ) {
36633680 addProp ( el , name , value ) ;
36643681 } else {
36653682 addAttr ( el , name , value ) ;
@@ -3840,8 +3857,8 @@ var modifierCode = {
38403857 self : 'if($event.target !== $event.currentTarget)return;'
38413858} ;
38423859
3843- function genHandlers ( events ) {
3844- var res = 'on:{' ;
3860+ function genHandlers ( events , native ) {
3861+ var res = native ? 'nativeOn:{' : 'on:{' ;
38453862 for ( var name in events ) {
38463863 res += '"' + name + '":' + genHandler ( events [ name ] ) + ',' ;
38473864 }
@@ -3879,7 +3896,7 @@ function genKeyFilter(key) {
38793896}
38803897
38813898function bind$1 ( el , dir ) {
3882- addHook ( el , 'construct' , '_b(n1,' + dir . value + ')' ) ;
3899+ addHook ( el , 'construct' , '_b(n1,' + dir . value + ( dir . modifiers && dir . modifiers . prop ? ',true' : '' ) + ')' ) ;
38833900}
38843901
38853902var baseDirectives = {
@@ -4013,10 +4030,6 @@ function genData(el) {
40134030 if ( el . attrsMap [ 'v-show' ] ) {
40144031 data += 'show:true,' ;
40154032 }
4016- // props
4017- if ( el . props ) {
4018- data += 'props:{' + genProps ( el . props ) + '},' ;
4019- }
40204033 // attributes
40214034 if ( el . attrs ) {
40224035 data += 'attrs:{' + genProps ( el . attrs ) + '},' ;
@@ -4025,6 +4038,10 @@ function genData(el) {
40254038 if ( el . staticAttrs ) {
40264039 data += 'staticAttrs:{' + genProps ( el . staticAttrs ) + '},' ;
40274040 }
4041+ // DOM props
4042+ if ( el . props ) {
4043+ data += 'domProps:{' + genProps ( el . props ) + '},' ;
4044+ }
40284045 // hooks
40294046 if ( el . hooks ) {
40304047 data += 'hook:{' + genHooks ( el . hooks ) + '},' ;
@@ -4033,6 +4050,9 @@ function genData(el) {
40334050 if ( el . events ) {
40344051 data += genHandlers ( el . events ) + ',' ;
40354052 }
4053+ if ( el . nativeEvents ) {
4054+ data += '' + genHandlers ( el . nativeEvents , true ) ;
4055+ }
40364056 // inline-template
40374057 if ( el . inlineTemplate ) {
40384058 var ast = el . children [ 0 ] ;
@@ -4287,7 +4307,7 @@ function genCheckboxModel(el, value) {
42874307 var trueValueBinding = getBindingAttr ( el , 'true-value' ) || 'true' ;
42884308 var falseValueBinding = getBindingAttr ( el , 'false-value' ) || 'false' ;
42894309 addProp ( el , 'checked' , 'Array.isArray(' + value + ')' + ( '?(' + value + ').indexOf(' + valueBinding + ')>-1' ) + ( ':(' + value + ')===(' + trueValueBinding + ')' ) ) ;
4290- addHandler ( el , 'change' , 'var $$a=' + value + ',' + '$$el=$event.target,' + ( '$$c=$$el.checked?(' + trueValueBinding + '):(' + falseValueBinding + ');' ) + 'if(Array.isArray($$a)){' + ( 'var $$v=' + valueBinding + ',' ) + '$$i=$$a.indexOf($$v);' + 'if($$c){$$i<0&&$$a.push ($$v)}' + 'else{$$i>-1&&$$a.splice( $$i,1)}' + ( '}else{' + value + '=$$c}' ) ) ;
4310+ addHandler ( el , 'change' , 'var $$a=' + value + ',' + '$$el=$event.target,' + ( '$$c=$$el.checked?(' + trueValueBinding + '):(' + falseValueBinding + ');' ) + 'if(Array.isArray($$a)){' + ( 'var $$v=' + valueBinding + ',' ) + '$$i=$$a.indexOf($$v);' + ( 'if($$c){$$i<0&&(' + value + '= $$a.concat ($$v))}' ) + ( 'else{$$i>-1&&(' + value + '= $$a.slice(0, $$i).concat($$a.slice($$i+1)))}' ) + ( '}else{' + value + '=$$c}' ) ) ;
42914311}
42924312
42934313function genRadioModel ( el , value ) {
@@ -4505,7 +4525,7 @@ function createRenderFunction(modules, directives, isUnaryTag, cache) {
45054525 if ( node . tag ) {
45064526 renderElement ( node , write , next , isRoot ) ;
45074527 } else {
4508- write ( node . raw ? node . text : entities . encodeHTML ( node . text ) , next ) ;
4528+ write ( node . raw ? node . text : entities . encodeHTML ( String ( node . text ) ) , next ) ;
45094529 }
45104530 }
45114531 }
@@ -4756,8 +4776,8 @@ function renderAttr(key, value) {
47564776 return '' ;
47574777}
47584778
4759- function props ( node ) {
4760- var props = node . data . props ;
4779+ function domProps ( node ) {
4780+ var props = node . data . domProps ;
47614781 var res = '' ;
47624782 if ( props ) {
47634783 for ( var key in props ) {
@@ -4805,7 +4825,7 @@ function renderStyle(node) {
48054825 }
48064826}
48074827
4808- var modules$1 = [ renderAttrs , props , renderClass , renderStyle ] ;
4828+ var modules$1 = [ renderAttrs , domProps , renderClass , renderStyle ] ;
48094829
48104830function show ( node , dir ) {
48114831 if ( ! dir . value ) {
0 commit comments