web-runtime.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* @flow */
  2. import Vue from 'core/index'
  3. import config from 'core/config'
  4. import { extend, noop } from 'shared/util'
  5. import { devtools, inBrowser } from 'core/util/index'
  6. import { patch } from 'web/runtime/patch'
  7. import platformDirectives from 'web/runtime/directives/index'
  8. import platformComponents from 'web/runtime/components/index'
  9. import { query, isUnknownElement, isReservedTag, mustUseProp } from 'web/util/index'
  10. // install platform specific utils
  11. Vue.config.isUnknownElement = isUnknownElement
  12. Vue.config.isReservedTag = isReservedTag
  13. Vue.config.mustUseProp = mustUseProp
  14. // install platform runtime directives & components
  15. extend(Vue.options.directives, platformDirectives)
  16. extend(Vue.options.components, platformComponents)
  17. // install platform patch function
  18. Vue.prototype.__patch__ = config._isServer ? noop : patch
  19. // wrap mount
  20. Vue.prototype.$mount = function (
  21. el?: string | Element,
  22. hydrating?: boolean
  23. ): Component {
  24. return this._mount(el && query(el), hydrating)
  25. }
  26. // devtools global hook
  27. /* istanbul ignore next */
  28. setTimeout(() => {
  29. if (config.devtools) {
  30. if (devtools) {
  31. devtools.emit('init', Vue)
  32. } else if (
  33. process.env.NODE_ENV !== 'production' &&
  34. inBrowser && /Chrome\/\d+/.test(window.navigator.userAgent)
  35. ) {
  36. console.log(
  37. 'Download the Vue Devtools for a better development experience:\n' +
  38. 'https://github.com/vuejs/vue-devtools'
  39. )
  40. }
  41. }
  42. }, 0)
  43. export default Vue