@@ -2,7 +2,6 @@ var Vue // late bind
22var version
33var map = window . __VUE_HOT_MAP__ = Object . create ( null )
44var installed = false
5- var isBrowserify = false
65var initHookName = 'beforeCreate'
76
87exports . install = function ( vue , browserify ) {
@@ -11,7 +10,6 @@ exports.install = function (vue, browserify) {
1110
1211 Vue = vue . __esModule ? vue . default : vue
1312 version = Vue . version . split ( '.' ) . map ( Number )
14- isBrowserify = browserify
1513
1614 // compat with < 2.0.0-alpha.7
1715 if ( Vue . config . _lifecycleHooks . indexOf ( 'init' ) > - 1 ) {
@@ -45,7 +43,7 @@ exports.createRecord = function (id, options) {
4543 makeOptionsHot ( id , options )
4644 map [ id ] = {
4745 Ctor : Vue . extend ( options ) ,
48- instances : [ ]
46+ instances : [ ] ,
4947 }
5048}
5149
@@ -86,35 +84,45 @@ function injectHook (options, name, hook) {
8684
8785function tryWrap ( fn ) {
8886 return function ( id , arg ) {
89- try {
90- return fn ( id , arg )
91- } catch ( e ) {
87+ try { fn ( id , arg ) } catch ( e ) {
9288 console . error ( e )
9389 console . warn ( 'Something went wrong during Vue component hot-reload. Full reload required.' )
9490 throw e
9591 }
9692 }
9793}
9894
99- exports . rerender = tryWrap ( function ( id , fns ) {
95+ exports . rerender = tryWrap ( function ( id , options ) {
10096 var record = map [ id ]
101- record . Ctor . options . render = fns . render
102- record . Ctor . options . staticRenderFns = fns . staticRenderFns
97+ console . log ( id , record , map )
98+ if ( typeof options === 'function' ) {
99+ options = options . options
100+ }
101+ console . log ( options )
102+ record . Ctor . options . render = options . render
103+ record . Ctor . options . staticRenderFns = options . staticRenderFns
103104 record . instances . slice ( ) . forEach ( function ( instance ) {
104- instance . $options . render = fns . render
105- instance . $options . staticRenderFns = fns . staticRenderFns
105+ instance . $options . render = options . render
106+ instance . $options . staticRenderFns = options . staticRenderFns
106107 instance . _staticTrees = [ ] // reset static trees
107108 instance . $forceUpdate ( )
108109 } )
109110} )
110111
111112exports . reload = tryWrap ( function ( id , options ) {
113+ if ( typeof options === 'function' ) {
114+ options = options . options
115+ }
112116 makeOptionsHot ( id , options )
113117 var record = map [ id ]
114- record . Ctor . extendOptions = options
115- var newCtor = Vue . extend ( options )
118+ if ( version [ 1 ] < 2 ) {
119+ // preserve pre 2.2 behavior for global mixin handling
120+ record . Ctor . extendOptions = options
121+ }
122+ var newCtor = record . Ctor . super . extend ( options )
116123 record . Ctor . options = newCtor . options
117124 record . Ctor . cid = newCtor . cid
125+ record . Ctor . prototype = newCtor . prototype
118126 if ( newCtor . release ) {
119127 // temporary global mixin strategy used in < 2.0.0-alpha.6
120128 newCtor . release ( )
@@ -125,8 +133,8 @@ exports.reload = tryWrap(function (id, options) {
125133 instance . $vnode . context . $forceUpdate ( )
126134 } else {
127135 console . warn ( 'Root or manually mounted instance modified. Full reload required.' )
128- needsReload = true ;
136+ needsReload = true
129137 }
130- } ) ;
138+ } )
131139 return needsReload
132140} )
0 commit comments