8000 move global api to a more proper place · GouTao/vue@e0e4062 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit e0e4062

Browse files
committed
move global api to a more proper place
1 parent 353cb3d commit e0e4062

File tree

4 files changed

+41
-38
lines changed

4 files changed

+41
-38
lines changed

src/instance/api/global.js renamed to src/global-api.js

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,43 @@ import {
1010
warn,
1111
isPlainObject,
1212
extend
13-
} from '../../util/index'
14-
15-
import config from '../../config'
16-
import * as util from '../../util/index'
17-
import * as compiler from '../../compiler/index'
18-
import * as path from '../../parsers/path'
19-
import * as text from '../../parsers/text'
20-
import * as template from '../../parsers/template'
21-
import * as directive from '../../parsers/directive'
22-
import * as expression from '../../parsers/expression'
23-
import * as transition from '../../transition/index'
24-
import FragmentFactory from '../../fragment/factory'
25-
import internalDirectives from '../../directives/internal/index'
13+
} from './util/index'
14+
15+
import config from './config'
16+
import directives from './directives/public/index'
17+
import elementDirectives from './directives/element/index'
18+
import filters from './filters/index'
19+
import * as util from './util/index'
20+
import * as compiler from './compiler/index'
21+
import * as path from './parsers/path'
22+
import * as text from './parsers/text'
23+
import * as template from './parsers/template'
24+
import * as directive from './parsers/directive'
25+
import * as expression from './parsers/expression'
26+
import * as transition from './transition/index'
27+
import FragmentFactory from './fragment/factory'
28+
import internalDirectives from './directives/internal/index'
2629

2730
export default function (Vue) {
31+
/**
32+
* Vue and every constructor that extends Vue has an
33+
* associated options object, which can be accessed during
34+
* compilation steps as `this.constructor.options`.
35+
*
36+
* These can be seen as the default options of every
37+
* Vue instance.
38+
*/
39+
40+
Vue.options = {
41+
directives,
42+
elementDirectives,
43+
filters,
44+
transitions: {},
45+
components: {},
46+
partials: {},
47+
replace: true
48+
}
49+
2850
/**
2951
* Expose useful internals
3052
*/

src/index.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,10 @@
11
import Vue from './instance/vue'
2-
import directives from './directives/public/index'
3-
import elementDirectives from './directives/element/index'
4-
import filters from './filters/index'
2+
import installGlobalAPI from './global-api'
53
import { inBrowser, devtools } from './util/index'
64

7-
Vue.version = '1.0.16'
8-
9-
/**
10-
* Vue and every constructor that extends Vue has an
11-
* associated options object, which can be accessed during
12-
* compilation steps as `this.constructor.options`.
13-
*
14-
* These can be seen as the default options of every
15-
* Vue instance.
16-
*/
5+
installGlobalAPI(Vue)
176

18-
Vue.options = {
19-
directives,
20-
elementDirectives,
21-
filters,
22-
transitions: {},
23-
components: {},
24-
partials: {},
25-
replace: true
26-
}
7+
Vue.version = '1.0.16'
278

289
export default Vue
2910

src/instance/vue.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import eventsMixin from './internal/events'
44
import lifecycleMixin from './internal/lifecycle'
55
import miscMixin from './internal/misc'
66

7-
import globalAPI from './api/global'
87
import dataAPI from './api/data'
98
import domAPI from './api/dom'
109
import eventsAPI from './api/events'
@@ -35,8 +34,7 @@ eventsMixin(Vue)
3534
lifecycleMixin(Vue)
3635
miscMixin(Vue)
3736

38-
// install APIs
39-
globalAPI(Vue)
37+
// install instance APIs
4038
dataAPI(Vue)
4139
domAPI(Vue)
4240
eventsAPI(Vue)

test/unit/specs/api/global_spec.js renamed to test/unit/specs/global_api_spec.js

Lines changed: 2 additions & 0 deletions
< 70B1 td data-grid-cell-id="diff-ce77c8e7b63e23294ebefad883e14556a4f3fa83e76eb5e8f36423040b167410-5-6-1" data-selected="false" role="gridcell" style="background-color:var(--bgColor-default);text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative diff-line-number-neutral left-side">6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var Vue = require('src')
22
var _ = require('src/util')
33
var config = require('src/config')
4+
var transition = require('src/transition')
45

5
describe('Global API', function () {
67
beforeEach(function () {
@@ -11,6 +12,7 @@ describe('Global API', function () {
1112
expect(Vue.util).toBe(_)
1213
expect(Vue.nextTick).toBe(_.nextTick)
1314
expect(Vue.config).toBe(config)
15+
expect(Vue.transition.applyTransition).toBe(transition.applyTransition)
1416
})
1517

1618
it('extend', function () {

0 commit comments

Comments
 (0)
0