Skip to content

Commit 2fe1e44

Browse files
author
zhuxy607
committed
add 2.6.4 debugger
1 parent 53baeaf commit 2fe1e44

File tree

537 files changed

+98355
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

537 files changed

+98355
-3
lines changed

2.6.0/src/compiler/create-compiler.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { extend } from 'shared/util'
44
import { detectErrors } from './error-detector'
55
import { createCompileToFunctionFn } from './to-function'
66

7+
/**
8+
* 创建编译器创建器
9+
*
10+
* @param baseCompile 基础编译函数
11+
* @returns 返回一个创建编译器的函数
12+
*/
713
export function createCompilerCreator (baseCompile: Function): Function {
814
return function createCompiler (baseOptions: CompilerOptions) {
915
function compile (
@@ -69,7 +75,7 @@ export function createCompilerCreator (baseCompile: Function): Function {
6975

7076
return {
7177
compile,
72-
// 编译模板的方法
78+
// 编译模板的方法(这个方法对应的就是 $mount 里的 compileToFunctions)
7379
compileToFunctions: createCompileToFunctionFn(compile)
7480
}
7581
}

2.6.0/src/compiler/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { createCompilerCreator } from './create-compiler'
88
// `createCompilerCreator` allows creating compilers that use alternative
99
// parser/optimizer/codegen, e.g the SSR optimizing compiler.
1010
// Here we just export a default compiler using the default parts.
11+
1112
export const createCompiler = createCompilerCreator(function baseCompile (
1213
template: string,
1314
options: CompilerOptions

2.6.0/src/compiler/parser/html-parser.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ function decodeAttr (value, shouldDecodeNewlines) {
5050
return value.replace(re, match => decodingMap[match])
5151
}
5252

53+
/**
54+
* 解析HTML模板,将模板转化为虚拟DOM节点
55+
*
56+
* @param html HTML模板字符串
57+
* @param options 解析选项
58+
* @returns 虚拟DOM节点数组
59+
*/
5360
export function parseHTML (html, options) {
5461
const stack = []
5562
const expectHTML = options.expectHTML
@@ -62,7 +69,9 @@ export function parseHTML (html, options) {
6269
last = html
6370
// Make sure we're not in a plaintext content element like script/style
6471
if (!lastTag || !isPlainTextElement(lastTag)) {
72+
6573
let textEnd = html.indexOf('<')
74+
6675
if (textEnd === 0) {
6776
// Comment:
6877
if (comment.test(html)) {
@@ -179,6 +188,11 @@ export function parseHTML (html, options) {
179188
// Clean up any remaining tags
180189
parseEndTag()
181190

191+
// 把匹配到的字符串切割掉
192+
// 匹配头标签之前 html:
193+
// <div :class="c" class="demo" v-if="isShow"><span v-for="item in sz">{{item}}</span></div>
194+
// 匹配头标签之后 html:
195+
// <span v-for="item in sz">{{item}}</span></div>
182196
function advance (n) {
183197
index += n
184198
html = html.substring(n)

2.6.0/src/core/instance/state.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,16 @@ function initProps(vm: Component, propsOptions: Object) {
102102
}
103103
});
104104
} else {
105+
// const props = (vm._props = {});
106+
// 将键和值通过 defineReactive 函数添加到 props(即vm._props)中
105107
defineReactive(props, key, value);
106108
}
107109
// static props are already proxied on the component's prototype
108110
// during Vue.extend(). We only need to proxy props defined at
109111
// instantiation here.
110-
// vm.x 实际访问的是 vm._props.x
112+
113+
// 判断这个key在当前实例vm中是否存在,如果不存在,则调用proxy函数在vm上设置一个以key为属性的代码,
114+
// 当使用vm[key]访问数据时,其实访问的是vm._props[key]
111115
if (!(key in vm)) {
112116
proxy(vm, `_props`, key);
113117
}
@@ -296,6 +300,7 @@ function initMethods(vm: Component, methods: Object) {
296300
);
297301
}
298302
}
303+
// 绑定方法到实例上同时把方法中的 this 绑定为 vm 实例
299304
vm[key] =
300305
typeof methods[key] !== "function" ? noop : bind(methods[key], vm);
301306
}

2.6.0/src/platforms/web/compiler/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @flow */
22

33
import { baseOptions } from './options'
4-
import { createCompiler } from 'compiler/index'
4+
import { createCompiler } from '../../../compiler/index'
55

66
const { compile, compileToFunctions } = createCompiler(baseOptions)
77

vue-2.6.14/.babelrc.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const babelPresetFlowVue = {
2+
plugins: [
3+
require('@babel/plugin-proposal-class-properties'),
4+
// require('@babel/plugin-syntax-flow'), // not needed, included in transform-flow-strip-types
5+
require('@babel/plugin-transform-flow-strip-types')
6+
]
7+
}
8+
9+
module.exports = {
10+
presets: [
11+
require('@babel/preset-env'),
12+
// require('babel-preset-flow-vue')
13+
babelPresetFlowVue
14+
],
15+
plugins: [
16+
require('babel-plugin-transform-vue-jsx'),
17+
require('@babel/plugin-syntax-dynamic-import')
18+
],
19+
ignore: [
20+
'dist/*.js',
21+
'packages/**/*.js'
22+
]
23+
}

vue-2.6.14/.circleci/config.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
version: 2
2+
3+
defaults: &defaults
4+
working_directory: ~/project/vue
5+
docker:
6+
- image: vuejs/ci
7+
8+
jobs:
9+
install:
10+
<<: *defaults
11+
steps:
12+
- checkout
13+
- restore_cache:
14+
keys:
15+
- v1-vue-{{ .Branch }}-{{ checksum "yarn.lock" }}
16+
- v1-vue-{{ .Branch }}-
17+
- v1-vue-
18+
- run: npm install
19+
- save_cache:
20+
key: v1-vue-{{ .Branch }}-{{ checksum "yarn.lock" }}
21+
paths:
22+
- node_modules/
23+
- persist_to_workspace:
24+
root: ~/project
25+
paths:
26+
- vue
27+
28+
lint-flow-types:
29+
<<: *defaults
30+
steps:
31+
- attach_workspace:
32+
at: ~/project
33+
- run: npm run lint
34+
- run: npm run flow
35+
- run: npm run test:types
36+
37+
test-cover:
38+
<<: *defaults
39+
steps:
40+
- attach_workspace:
41+
at: ~/project
42+
- run: npm run test:cover
43+
- run:
44+
name: report coverage stats for non-PRs
45+
command: |
46+
if [[ -z $CI_PULL_REQUEST ]]; then
47+
./node_modules/.bin/codecov
48+
fi
49+
50+
test-e2e:
51+
<<: *defaults
52+
steps:
53+
- attach_workspace:
54+
at: ~/project
55+
- run: npm run test:e2e -- --env phantomjs
56+
57+
test-ssr-weex:
58+
<<: *defaults
59+
steps:
60+
- attach_workspace:
61+
at: ~/project
62+
- run: npm run test:ssr
63+
- run: npm run test:weex
64+
65+
trigger-regression-test:
66+
<<: *defaults
67+
steps:
68+
- run:
69+
command: |
70+
curl --user ${CIRCLE_TOKEN}: \
71+
--data build_parameters[CIRCLE_JOB]=update \
72+
--data build_parameters[VUE_REVISION]=${CIRCLE_SHA1} \
73+
https://circleci.com/api/v1.1/project/github/vuejs/regression-testing/tree/master
74+
75+
workflows:
76+
version: 2
77+
install-and-parallel-test:
78+
jobs:
79+
- install
80+
- test-cover:
81+
requires:
82+
- install
83+
- lint-flow-types:
84+
requires:
85+
- install
86+
- test-e2e:
87+
requires:
88+
- install
89+
- test-ssr-weex:
90+
requires:
91+
- install
92+
- trigger-regression-test:
93+
filters:
94+
branches:
95+
only:
96+
- "2.6"
97+
- regression-test
98+
requires:
99+
- test-cover
100+
- lint-flow-types
101+
- test-e2e
102+
- test-ssr-weex
103+
weekly_regression_test:
104+
triggers:
105+
- schedule:
106+
# At 13:00 UTC (9:00 EDT) on every Monday
107+
cron: "0 13 * * 1"
108+
filters:
109+
branches:
110+
only:
111+
dev
112+
jobs:
113+
- install
114+
- test-cover:
115+
requires:
116+
- install
117+
- lint-flow-types:
118+
requires:
119+
- install
120+
- test-e2e:
121+
requires:
122+
- install
123+
- test-ssr-weex:
124+
requires:
125+
- install
126+
- trigger-regression-test:
127+
requires:
128+
- test-cover
129+
- lint-flow-types
130+
- test-e2e
131+
- test-ssr-weex

vue-2.6.14/.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# https://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
insert_final_newline = false
15+
trim_trailing_whitespace = false

vue-2.6.14/.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
flow
2+
dist
3+
packages

vue-2.6.14/.eslintrc.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
parser: require.resolve('babel-eslint'),
5+
ecmaVersion: 2018,
6+
sourceType: 'module'
7+
},
8+
env: {
9+
es6: true,
10+
node: true,
11+
browser: true
12+
},
13+
plugins: [
14+
"flowtype"
15+
],
16+
extends: [
17+
"eslint:recommended",
18+
"plugin:flowtype/recommended"
19+
],
20+
globals: {
21+
"__WEEX__": true,
22+
"WXEnvironment": true
23+
},
24+
rules: {
25+
'no-console': process.env.NODE_ENV !== 'production' ? 0 : 2,
26+
'no-useless-escape': 0,
27+
'no-empty': 0
28+
}
29+
}

0 commit comments

Comments
 (0)