File tree Expand file tree Collapse file tree 2 files changed +25
-6
lines changed
test/specs/mounting-options Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,24 @@ export default function createInstance(
7373
7474 // make sure all extends are based on this instance
7575
76+ if ( instanceOptions . watch ) {
77+ console . log ( instanceOptions . watch )
78+ }
79+
80+ // watchers provided in mounting options should override preexisting ones
81+ if ( componentOptions . watch && instanceOptions . watch ) {
82+ const componentWatchers = Object . keys ( componentOptions . watch )
83+ const instanceWatchers = Object . keys ( instanceOptions . watch )
84+
85+ for ( let i = 0 ; i < instanceWatchers . length ; i ++ ) {
86+ const k = instanceWatchers [ i ]
87+ // override the componentOptions with the one provided in mounting options
88+ if ( componentWatchers . includes ( k ) ) {
89+ componentOptions . watch [ k ] = instanceOptions . watch [ k ]
90+ }
91+ }
92+ }
93+
7694 const Constructor = _Vue . extend ( componentOptions ) . extend ( instanceOptions )
7795 componentOptions . _Ctor = { }
7896 Constructor . options . _base = _Vue
Original file line number Diff line number Diff line change 1- import {
2- describeWithShallowAndMount ,
3- isRunningPhantomJS ,
4- vueVersion
5- } from '~resources/utils'
1+ import { describeWithShallowAndMount } from '~resources/utils'
62import { itSkipIf , itDoNotRunIf } from 'conditional-specs'
73
84describeWithShallowAndMount ( 'options.watch' , mountingMethod => {
95 it ( 'overrides a default watch handler' , async ( ) => {
106 const TestComponent = {
11- props : [ 'someProp' ] ,
7+ props : [ 'someProp' , 'anotherProp' ] ,
128 template : '<div>{{ foo }}</div>' ,
139 data ( ) {
1410 return {
1511 foo : 'bar'
1612 }
1713 } ,
1814 watch : {
15+ anotherProp : {
16+ handler ( ) {
17+ // placeholder
18+ }
19+ } ,
1920 someProp : {
2021 handler ( ) {
2122 this . foo = 'updated-bar'
You can’t perform that action at this time.
0 commit comments