File tree Expand file tree Collapse file tree 3 files changed +36
-7
lines changed Expand file tree Collapse file tree 3 files changed +36
-7
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ export type Config = {
66 // user
77 optionMergeStrategies : { [ key : string ] : Function } ,
88 silent : boolean ,
9+ devtools : boolean ,
910 errorHandler : ?Function ,
1011 ignoredElements : ?Array < string > ,
1112 keyCodes : { [ key : string ] : number } ,
@@ -32,6 +33,11 @@ const config: Config = {
3233 */
3334 silent : false ,
3435
36+ /**
37+ * Whether to enable devtools
38+ */
39+ devtools : process . env . NODE_ENV !== 'production' ,
40+
3541 /**
3642 * Error handler for watcher errors
3743 */
Original file line number Diff line number Diff line change @@ -4,15 +4,14 @@ import type Watcher from './watcher'
44import config from '../config'
55import {
66 warn ,
7- nextTick
7+ nextTick ,
8+ devtools
89} from '../util/index'
910
10- // we have two separate queues: one for directive updates
11- // and one for user watcher registered via $watch().
12- // we want to guarantee directive updates to be called
13- // before user watchers so that when user watchers are
14- // triggered, the DOM would have already been in updated
15- // state.
11+ // We have two separate queues: one for internal component re-render updates
12+ // and one for user watcher registered via $watch(). We want to guarantee
13+ // re-render updates to be called before user watchers so that when user
14+ // watchers are triggered, the DOM would already be in updated state.
1615
1716const queue : Array < Watcher > = []
1817const userQueue: Array< Watcher > = []
@@ -44,6 +43,11 @@ function flushSchedulerQueue () {
4443 if ( queue . length ) {
4544 return flushSchedulerQueue ( )
4645 }
46+ // devtool hook
47+ /* istanbul ignore if */
48+ if (devtools && config . devtools ) {
49+ devtools . emit ( 'flush' )
50+ }
4751 resetSchedulerState()
4852}
4953
Original file line number Diff line number Diff line change 33import Vue from 'core/index'
44import config from 'core/config'
55import { extend , noop } from 'shared/util'
6+ import { devtools , inBrowser } from 'core/util/index'
67import { patch } from 'web/runtime/patch'
78import platformDirectives from 'web/runtime/directives/index'
89import platformComponents from 'web/runtime/components/index'
@@ -28,4 +29,22 @@ Vue.prototype.$mount = function (
2829 return this . _mount ( el && query ( el ) , hydrating )
2930}
3031
32+ // devtools global hook
33+ /* istanbul ignore next */
34+ setTimeout ( ( ) => {
35+ if ( config . devtools ) {
36+ if ( devtools ) {
37+ devtools . emit ( 'init' , Vue )
38+ } else if (
39+ process . env . NODE_ENV !== 'production' &&
40+ inBrowser && / C h r o m e \/ \d + / . test ( window . navigator . userAgent )
41+ ) {
42+ console . log (
43+ 'Download the Vue Devtools for a better development experience:\n' +
44+ 'https://github.com/vuejs/vue-devtools'
45+ )
46+ }
47+ }
48+ } , 0 )
49+
3150export default Vue
You can’t perform that action at this time.
0 commit comments