vue 2.6.13 → 2.7.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -295
- package/compiler-sfc/index.d.ts +1 -0
- package/compiler-sfc/index.js +1 -0
- package/compiler-sfc/index.mjs +1 -0
- package/compiler-sfc/package.json +5 -0
- package/dist/vue.common.dev.js +11481 -11946
- package/dist/vue.common.prod.js +8 -3
- package/dist/vue.esm.browser.js +11321 -12011
- package/dist/vue.esm.browser.min.js +8 -3
- package/dist/vue.esm.js +11476 -11984
- package/dist/vue.js +11484 -11949
- package/dist/vue.min.js +8 -3
- package/dist/vue.runtime.common.dev.js +8427 -8421
- package/dist/vue.runtime.common.prod.js +8 -3
- package/dist/vue.runtime.esm.js +8436 -8454
- package/dist/vue.runtime.js +8430 -8424
- package/dist/vue.runtime.min.js +8 -3
- package/package.json +88 -111
- package/packages/compiler-sfc/dist/compiler-sfc.js +7 -0
- package/packages/compiler-sfc/node_modules/.bin/parser +17 -0
- package/packages/compiler-sfc/node_modules/.bin/sass +17 -0
- package/packages/compiler-sfc/package.json +30 -0
- package/src/compiler/{codeframe.js → codeframe.ts} +9 -7
- package/src/compiler/codegen/{events.js → events.ts} +21 -41
- package/src/compiler/codegen/{index.js → index.ts} +146 -136
- package/src/compiler/{create-compiler.js → create-compiler.ts} +26 -18
- package/src/compiler/directives/bind.ts +9 -0
- package/src/compiler/directives/{index.js → index.ts} +0 -2
- package/src/compiler/directives/{model.js → model.ts} +15 -18
- package/src/compiler/directives/{on.js → on.ts} +3 -4
- package/src/compiler/{error-detector.js → error-detector.ts} +61 -31
- package/src/compiler/{helpers.js → helpers.ts} +73 -61
- package/src/compiler/{index.js → index.ts} +2 -3
- package/src/compiler/{optimizer.js → optimizer.ts} +30 -23
- package/src/compiler/parser/{entity-decoder.js → entity-decoder.ts} +1 -3
- package/src/compiler/parser/{filter-parser.js → filter-parser.ts} +43 -24
- package/src/compiler/parser/{html-parser.js → html-parser.ts} +50 -29
- package/src/compiler/parser/{index.js → index.ts} +190 -172
- package/src/compiler/parser/{text-parser.js → text-parser.ts} +8 -9
- package/src/compiler/{to-function.js → to-function.ts} +27 -22
- package/src/core/components/{index.js → index.ts} +0 -0
- package/src/core/components/{keep-alive.js → keep-alive.ts} +42 -30
- package/src/core/{config.js → config.ts} +28 -30
- package/src/core/global-api/{assets.js → assets.ts} +8 -7
- package/src/core/global-api/{extend.js → extend.ts} +10 -13
- package/src/core/global-api/{index.js → index.ts} +4 -5
- package/src/core/global-api/{mixin.js → mixin.ts} +2 -3
- package/src/core/global-api/use.ts +23 -0
- package/src/core/{index.js → index.ts} +1 -1
- package/src/core/instance/{events.js → events.ts} +41 -24
- package/src/core/instance/{index.js → index.ts} +9 -5
- package/src/core/instance/{init.js → init.ts} +26 -15
- package/src/core/instance/inject.ts +72 -0
- package/src/core/instance/{lifecycle.js → lifecycle.ts} +86 -44
- package/src/core/instance/{proxy.js → proxy.ts} +29 -24
- package/src/core/instance/render-helpers/{bind-dynamic-keys.js → bind-dynamic-keys.ts} +6 -5
- package/src/core/instance/render-helpers/{bind-object-listeners.js → bind-object-listeners.ts} +4 -8
- package/src/core/instance/render-helpers/{bind-object-props.js → bind-object-props.ts} +12 -17
- package/src/core/instance/render-helpers/{check-keycodes.js → check-keycodes.ts} +5 -7
- package/src/core/instance/render-helpers/{index.js → index.ts} +1 -3
- package/src/core/instance/render-helpers/{render-list.js → render-list.ts} +12 -13
- package/src/core/instance/render-helpers/{render-slot.js → render-slot.ts} +10 -11
- package/src/core/instance/render-helpers/{render-static.js → render-static.ts} +7 -10
- package/src/core/instance/render-helpers/{resolve-filter.js → resolve-filter.ts} +1 -3
- package/src/core/instance/render-helpers/{resolve-scoped-slots.js → resolve-scoped-slots.ts} +11 -8
- package/src/core/instance/render-helpers/{resolve-slots.js → resolve-slots.ts} +12 -11
- package/src/core/instance/{render.js → render.ts} +66 -29
- package/src/core/instance/{state.js → state.ts} +100 -83
- package/src/core/observer/{array.js → array.ts} +11 -2
- package/src/core/observer/{dep.js → dep.ts} +37 -15
- package/src/core/observer/{index.js → index.ts} +137 -71
- package/src/core/observer/{scheduler.js → scheduler.ts} +42 -43
- package/src/core/observer/{traverse.js → traverse.ts} +10 -7
- package/src/core/observer/{watcher.js → watcher.ts} +88 -60
- package/src/core/util/{debug.js → debug.ts} +38 -34
- package/src/core/util/{env.js → env.ts} +27 -30
- package/src/core/util/{error.js → error.ts} +12 -14
- package/src/core/util/{index.js → index.ts} +0 -2
- package/src/core/util/{lang.js → lang.ts} +6 -7
- package/src/core/util/{next-tick.js → next-tick.ts} +16 -10
- package/src/core/util/{options.js → options.ts} +119 -114
- package/src/core/util/{perf.js → perf.ts} +5 -1
- package/src/core/util/{props.js → props.ts} +54 -50
- package/src/core/vdom/{create-component.js → create-component.ts} +51 -50
- package/src/core/vdom/{create-element.js → create-element.ts} +49 -43
- package/src/core/vdom/{create-functional-component.js → create-functional-component.ts} +52 -27
- package/src/core/vdom/helpers/{extract-props.js → extract-props.ts} +18 -18
- package/src/core/vdom/helpers/{get-first-component-child.js → get-first-component-child.ts} +6 -5
- package/src/core/vdom/helpers/{index.js → index.ts} +0 -2
- package/src/core/vdom/helpers/is-async-placeholder.ts +6 -0
- package/src/core/vdom/helpers/{merge-hook.js → merge-hook.ts} +7 -5
- package/src/core/vdom/helpers/{normalize-children.js → normalize-children.ts} +26 -16
- package/src/core/vdom/helpers/{normalize-scoped-slots.js → normalize-scoped-slots.ts} +23 -17
- package/src/core/vdom/helpers/{resolve-async-component.js → resolve-async-component.ts} +29 -37
- package/src/core/vdom/helpers/update-listeners.ts +101 -0
- package/src/core/vdom/modules/{directives.js → directives.ts} +20 -14
- package/src/core/vdom/modules/index.ts +4 -0
- package/src/core/vdom/modules/template-ref.ts +96 -0
- package/src/core/vdom/{patch.js → patch.ts} +239 -138
- package/src/core/vdom/{vnode.js → vnode.ts} +36 -31
- package/src/global.d.ts +15 -0
- package/src/platforms/web/compiler/directives/html.ts +8 -0
- package/src/platforms/web/compiler/directives/{index.js → index.ts} +0 -0
- package/src/platforms/web/compiler/directives/{model.js → model.ts} +47 -41
- package/src/platforms/web/compiler/directives/{text.js → text.ts} +2 -3
- package/src/platforms/web/compiler/{index.js → index.ts} +0 -2
- package/src/platforms/web/compiler/modules/{class.js → class.ts} +10 -15
- package/src/platforms/web/compiler/modules/{index.js → index.ts} +1 -5
- package/src/platforms/web/compiler/modules/{model.js → model.ts} +6 -11
- package/src/platforms/web/compiler/modules/{style.js → style.ts} +9 -14
- package/src/platforms/web/compiler/{options.js → options.ts} +1 -2
- package/src/platforms/web/compiler/{util.js → util.ts} +5 -7
- package/src/platforms/web/entry-compiler-sfc.ts +1 -0
- package/src/platforms/web/{entry-compiler.js → entry-compiler.ts} +1 -3
- package/src/platforms/web/{entry-runtime.js → entry-runtime-esm.ts} +2 -2
- package/src/platforms/web/entry-runtime-with-compiler-esm.ts +5 -0
- package/src/platforms/web/entry-runtime-with-compiler.ts +10 -0
- package/src/platforms/web/entry-runtime.ts +7 -0
- package/src/platforms/web/runtime/{class-util.js → class-util.ts} +2 -4
- package/src/platforms/web/runtime/components/{index.js → index.ts} +0 -0
- package/src/platforms/web/runtime/components/{transition-group.js → transition-group.ts} +59 -46
- package/src/platforms/web/runtime/components/{transition.js → transition.ts} +43 -36
- package/src/platforms/web/runtime/directives/{index.js → index.ts} +0 -0
- package/src/platforms/web/runtime/directives/{model.js → model.ts} +22 -21
- package/src/platforms/web/runtime/directives/{show.js → show.ts} +11 -10
- package/src/platforms/web/runtime/{index.js → index.ts} +9 -10
- package/src/platforms/web/runtime/modules/{attrs.js → attrs.ts} +12 -16
- package/src/platforms/web/runtime/modules/{class.js → class.ts} +7 -18
- package/src/platforms/web/runtime/modules/{dom-props.js → dom-props.ts} +24 -17
- package/src/platforms/web/runtime/modules/{events.js → events.ts} +22 -15
- package/src/platforms/web/runtime/modules/{index.js → index.ts} +1 -8
- package/src/platforms/web/runtime/modules/{style.js → style.ts} +24 -13
- package/src/platforms/web/runtime/modules/{transition.js → transition.ts} +61 -63
- package/src/platforms/web/runtime/node-ops.ts +66 -0
- package/src/platforms/web/runtime/{patch.js → patch.ts} +0 -2
- package/src/platforms/web/runtime/{transition-util.js → transition-util.ts} +63 -38
- package/src/platforms/web/{entry-runtime-with-compiler.js → runtime-with-compiler.ts} +28 -19
- package/src/platforms/web/util/{attrs.js → attrs.ts} +18 -14
- package/src/platforms/web/util/{class.js → class.ts} +23 -21
- package/src/platforms/web/util/{compat.js → compat.ts} +4 -4
- package/src/platforms/web/util/{element.js → element.ts} +21 -22
- package/src/platforms/web/util/{index.js → index.ts} +2 -6
- package/src/platforms/web/util/{style.js → style.ts} +12 -12
- package/src/sfc/{parser.js → parser.ts} +18 -15
- package/src/shared/{constants.js → constants.ts} +2 -6
- package/src/shared/{util.js → util.ts} +78 -55
- package/src/types/compiler.ts +224 -0
- package/src/types/component.ts +209 -0
- package/src/types/global-api.ts +37 -0
- package/src/types/modules.d.ts +15 -0
- package/src/types/options.ts +120 -0
- package/src/types/ssr.ts +27 -0
- package/src/types/utils.ts +3 -0
- package/src/types/vnode.ts +127 -0
- package/src/v3/apiInject.ts +66 -0
- package/src/v3/apiLifecycle.ts +53 -0
- package/src/v3/apiSetup.ts +161 -0
- package/src/v3/apiWatch.ts +355 -0
- package/src/v3/currentInstance.ts +23 -0
- package/src/v3/debug.ts +21 -0
- package/src/v3/h.ts +18 -0
- package/src/v3/index.ts +77 -0
- package/src/v3/reactivity/computed.ts +100 -0
- package/src/v3/reactivity/effect.ts +20 -0
- package/src/v3/reactivity/effectScope.ts +134 -0
- package/src/v3/reactivity/operations.ts +14 -0
- package/src/v3/reactivity/reactive.ts +123 -0
- package/src/v3/reactivity/readonly.ts +121 -0
- package/src/v3/reactivity/ref.ts +249 -0
- package/types/index.d.ts +10 -13
- package/types/options.d.ts +265 -132
- package/types/plugin.d.ts +4 -4
- package/types/umd.d.ts +47 -27
- package/types/v3-generated.d.ts +389 -0
- package/types/v3.d.ts +16 -0
- package/types/vnode.d.ts +70 -57
- package/types/vue.d.ts +292 -88
- package/dist/README.md +0 -122
- package/src/compiler/directives/bind.js +0 -11
- package/src/core/global-api/use.js +0 -23
- package/src/core/instance/inject.js +0 -73
- package/src/core/vdom/helpers/is-async-placeholder.js +0 -5
- package/src/core/vdom/helpers/update-listeners.js +0 -95
- package/src/core/vdom/modules/index.js +0 -7
- package/src/core/vdom/modules/ref.js +0 -45
- package/src/platforms/web/compiler/directives/html.js +0 -9
- package/src/platforms/web/entry-server-basic-renderer.js +0 -13
- package/src/platforms/web/entry-server-renderer.js +0 -27
- package/src/platforms/web/runtime/node-ops.js +0 -59
- package/src/platforms/web/server/compiler.js +0 -11
- package/src/platforms/web/server/directives/index.js +0 -7
- package/src/platforms/web/server/directives/model.js +0 -44
- package/src/platforms/web/server/directives/show.js +0 -12
- package/src/platforms/web/server/modules/attrs.js +0 -67
- package/src/platforms/web/server/modules/class.js +0 -11
- package/src/platforms/web/server/modules/dom-props.js +0 -50
- package/src/platforms/web/server/modules/index.js +0 -11
- package/src/platforms/web/server/modules/style.js +0 -41
- package/src/platforms/web/server/util.js +0 -101
- package/src/platforms/weex/compiler/directives/index.js +0 -5
- package/src/platforms/weex/compiler/directives/model.js +0 -33
- package/src/platforms/weex/compiler/index.js +0 -52
- package/src/platforms/weex/compiler/modules/append.js +0 -27
- package/src/platforms/weex/compiler/modules/class.js +0 -74
- package/src/platforms/weex/compiler/modules/index.js +0 -13
- package/src/platforms/weex/compiler/modules/props.js +0 -37
- package/src/platforms/weex/compiler/modules/recycle-list/component-root.js +0 -13
- package/src/platforms/weex/compiler/modules/recycle-list/component.js +0 -16
- package/src/platforms/weex/compiler/modules/recycle-list/index.js +0 -60
- package/src/platforms/weex/compiler/modules/recycle-list/recycle-list.js +0 -50
- package/src/platforms/weex/compiler/modules/recycle-list/text.js +0 -23
- package/src/platforms/weex/compiler/modules/recycle-list/v-bind.js +0 -21
- package/src/platforms/weex/compiler/modules/recycle-list/v-for.js +0 -33
- package/src/platforms/weex/compiler/modules/recycle-list/v-if.js +0 -63
- package/src/platforms/weex/compiler/modules/recycle-list/v-on.js +0 -25
- package/src/platforms/weex/compiler/modules/recycle-list/v-once.js +0 -19
- package/src/platforms/weex/compiler/modules/style.js +0 -87
- package/src/platforms/weex/entry-compiler.js +0 -2
- package/src/platforms/weex/entry-framework.js +0 -187
- package/src/platforms/weex/entry-runtime-factory.js +0 -6
- package/src/platforms/weex/runtime/components/index.js +0 -9
- package/src/platforms/weex/runtime/components/richtext.js +0 -82
- package/src/platforms/weex/runtime/components/transition-group.js +0 -148
- package/src/platforms/weex/runtime/components/transition.js +0 -9
- package/src/platforms/weex/runtime/directives/index.js +0 -2
- package/src/platforms/weex/runtime/index.js +0 -42
- package/src/platforms/weex/runtime/modules/attrs.js +0 -44
- package/src/platforms/weex/runtime/modules/class.js +0 -76
- package/src/platforms/weex/runtime/modules/events.js +0 -54
- package/src/platforms/weex/runtime/modules/index.js +0 -13
- package/src/platforms/weex/runtime/modules/style.js +0 -84
- package/src/platforms/weex/runtime/modules/transition.js +0 -270
- package/src/platforms/weex/runtime/node-ops.js +0 -91
- package/src/platforms/weex/runtime/patch.js +0 -16
- package/src/platforms/weex/runtime/recycle-list/render-component-template.js +0 -34
- package/src/platforms/weex/runtime/recycle-list/virtual-component.js +0 -136
- package/src/platforms/weex/runtime/text-node.js +0 -9
- package/src/platforms/weex/util/element.js +0 -52
- package/src/platforms/weex/util/index.js +0 -40
- package/src/platforms/weex/util/parser.js +0 -60
- package/src/server/bundle-renderer/create-bundle-renderer.js +0 -151
- package/src/server/bundle-renderer/create-bundle-runner.js +0 -150
- package/src/server/bundle-renderer/source-map-support.js +0 -45
- package/src/server/create-basic-renderer.js +0 -37
- package/src/server/create-renderer.js +0 -152
- package/src/server/optimizing-compiler/codegen.js +0 -264
- package/src/server/optimizing-compiler/index.js +0 -20
- package/src/server/optimizing-compiler/modules.js +0 -124
- package/src/server/optimizing-compiler/optimizer.js +0 -141
- package/src/server/optimizing-compiler/runtime-helpers.js +0 -150
- package/src/server/render-context.js +0 -130
- package/src/server/render-stream.js +0 -95
- package/src/server/render.js +0 -437
- package/src/server/template-renderer/create-async-file-mapper.js +0 -57
- package/src/server/template-renderer/index.js +0 -277
- package/src/server/template-renderer/parse-template.js +0 -42
- package/src/server/template-renderer/template-stream.js +0 -82
- package/src/server/util.js +0 -18
- package/src/server/webpack-plugin/client.js +0 -65
- package/src/server/webpack-plugin/server.js +0 -66
- package/src/server/webpack-plugin/util.js +0 -34
- package/src/server/write.js +0 -50
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
1
|
const validDivisionCharRE = /[\w).+\-_$\]]/
|
|
4
2
|
|
|
5
|
-
export function parseFilters
|
|
3
|
+
export function parseFilters(exp: string): string {
|
|
6
4
|
let inSingle = false
|
|
7
5
|
let inDouble = false
|
|
8
6
|
let inTemplateString = false
|
|
@@ -17,18 +15,20 @@ export function parseFilters (exp: string): string {
|
|
|
17
15
|
prev = c
|
|
18
16
|
c = exp.charCodeAt(i)
|
|
19
17
|
if (inSingle) {
|
|
20
|
-
if (c === 0x27 && prev !==
|
|
18
|
+
if (c === 0x27 && prev !== 0x5c) inSingle = false
|
|
21
19
|
} else if (inDouble) {
|
|
22
|
-
if (c === 0x22 && prev !==
|
|
20
|
+
if (c === 0x22 && prev !== 0x5c) inDouble = false
|
|
23
21
|
} else if (inTemplateString) {
|
|
24
|
-
if (c === 0x60 && prev !==
|
|
22
|
+
if (c === 0x60 && prev !== 0x5c) inTemplateString = false
|
|
25
23
|
} else if (inRegex) {
|
|
26
|
-
if (c === 0x2f && prev !==
|
|
24
|
+
if (c === 0x2f && prev !== 0x5c) inRegex = false
|
|
27
25
|
} else if (
|
|
28
|
-
c ===
|
|
29
|
-
exp.charCodeAt(i + 1) !==
|
|
30
|
-
exp.charCodeAt(i - 1) !==
|
|
31
|
-
!curly &&
|
|
26
|
+
c === 0x7c && // pipe
|
|
27
|
+
exp.charCodeAt(i + 1) !== 0x7c &&
|
|
28
|
+
exp.charCodeAt(i - 1) !== 0x7c &&
|
|
29
|
+
!curly &&
|
|
30
|
+
!square &&
|
|
31
|
+
!paren
|
|
32
32
|
) {
|
|
33
33
|
if (expression === undefined) {
|
|
34
34
|
// first filter, end of expression
|
|
@@ -39,17 +39,36 @@ export function parseFilters (exp: string): string {
|
|
|
39
39
|
}
|
|
40
40
|
} else {
|
|
41
41
|
switch (c) {
|
|
42
|
-
case 0x22:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
case
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
case
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
case 0x22:
|
|
43
|
+
inDouble = true
|
|
44
|
+
break // "
|
|
45
|
+
case 0x27:
|
|
46
|
+
inSingle = true
|
|
47
|
+
break // '
|
|
48
|
+
case 0x60:
|
|
49
|
+
inTemplateString = true
|
|
50
|
+
break // `
|
|
51
|
+
case 0x28:
|
|
52
|
+
paren++
|
|
53
|
+
break // (
|
|
54
|
+
case 0x29:
|
|
55
|
+
paren--
|
|
56
|
+
break // )
|
|
57
|
+
case 0x5b:
|
|
58
|
+
square++
|
|
59
|
+
break // [
|
|
60
|
+
case 0x5d:
|
|
61
|
+
square--
|
|
62
|
+
break // ]
|
|
63
|
+
case 0x7b:
|
|
64
|
+
curly++
|
|
65
|
+
break // {
|
|
66
|
+
case 0x7d:
|
|
67
|
+
curly--
|
|
68
|
+
break // }
|
|
51
69
|
}
|
|
52
|
-
if (c === 0x2f) {
|
|
70
|
+
if (c === 0x2f) {
|
|
71
|
+
// /
|
|
53
72
|
let j = i - 1
|
|
54
73
|
let p
|
|
55
74
|
// find first non-whitespace prev char
|
|
@@ -70,8 +89,8 @@ export function parseFilters (exp: string): string {
|
|
|
70
89
|
pushFilter()
|
|
71
90
|
}
|
|
72
91
|
|
|
73
|
-
function pushFilter
|
|
74
|
-
(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim())
|
|
92
|
+
function pushFilter() {
|
|
93
|
+
;(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim())
|
|
75
94
|
lastFilterIndex = i + 1
|
|
76
95
|
}
|
|
77
96
|
|
|
@@ -84,7 +103,7 @@ export function parseFilters (exp: string): string {
|
|
|
84
103
|
return expression
|
|
85
104
|
}
|
|
86
105
|
|
|
87
|
-
function wrapFilter
|
|
106
|
+
function wrapFilter(exp: string, filter: string): string {
|
|
88
107
|
const i = filter.indexOf('(')
|
|
89
108
|
if (i < 0) {
|
|
90
109
|
// _f: resolveFilter
|
|
@@ -14,8 +14,10 @@ import { isNonPhrasingTag } from 'web/compiler/util'
|
|
|
14
14
|
import { unicodeRegExp } from 'core/util/lang'
|
|
15
15
|
|
|
16
16
|
// Regular Expressions for parsing tags and attributes
|
|
17
|
-
const attribute =
|
|
18
|
-
|
|
17
|
+
const attribute =
|
|
18
|
+
/^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/
|
|
19
|
+
const dynamicArgAttribute =
|
|
20
|
+
/^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/
|
|
19
21
|
const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*`
|
|
20
22
|
const qnameCapture = `((?:${ncname}\\:)?${ncname})`
|
|
21
23
|
const startTagOpen = new RegExp(`^<${qnameCapture}`)
|
|
@@ -44,15 +46,16 @@ const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g
|
|
|
44
46
|
|
|
45
47
|
// #5992
|
|
46
48
|
const isIgnoreNewlineTag = makeMap('pre,textarea', true)
|
|
47
|
-
const shouldIgnoreFirstNewline = (tag, html) =>
|
|
49
|
+
const shouldIgnoreFirstNewline = (tag, html) =>
|
|
50
|
+
tag && isIgnoreNewlineTag(tag) && html[0] === '\n'
|
|
48
51
|
|
|
49
|
-
function decodeAttr
|
|
52
|
+
function decodeAttr(value, shouldDecodeNewlines) {
|
|
50
53
|
const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr
|
|
51
54
|
return value.replace(re, match => decodingMap[match])
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
export function parseHTML
|
|
55
|
-
const stack = []
|
|
57
|
+
export function parseHTML(html, options) {
|
|
58
|
+
const stack: any[] = []
|
|
56
59
|
const expectHTML = options.expectHTML
|
|
57
60
|
const isUnaryTag = options.isUnaryTag || no
|
|
58
61
|
const canBeLeftOpenTag = options.canBeLeftOpenTag || no
|
|
@@ -70,7 +73,11 @@ export function parseHTML (html, options) {
|
|
|
70
73
|
|
|
71
74
|
if (commentEnd >= 0) {
|
|
72
75
|
if (options.shouldKeepComment) {
|
|
73
|
-
options.comment(
|
|
76
|
+
options.comment(
|
|
77
|
+
html.substring(4, commentEnd),
|
|
78
|
+
index,
|
|
79
|
+
index + commentEnd + 3
|
|
80
|
+
)
|
|
74
81
|
}
|
|
75
82
|
advance(commentEnd + 3)
|
|
76
83
|
continue
|
|
@@ -146,7 +153,12 @@ export function parseHTML (html, options) {
|
|
|
146
153
|
} else {
|
|
147
154
|
let endTagLength = 0
|
|
148
155
|
const stackedTag = lastTag.toLowerCase()
|
|
149
|
-
const reStackedTag =
|
|
156
|
+
const reStackedTag =
|
|
157
|
+
reCache[stackedTag] ||
|
|
158
|
+
(reCache[stackedTag] = new RegExp(
|
|
159
|
+
'([\\s\\S]*?)(</' + stackedTag + '[^>]*>)',
|
|
160
|
+
'i'
|
|
161
|
+
))
|
|
150
162
|
const rest = html.replace(reStackedTag, function (all, text, endTag) {
|
|
151
163
|
endTagLength = endTag.length
|
|
152
164
|
if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
|
|
@@ -169,8 +181,10 @@ export function parseHTML (html, options) {
|
|
|
169
181
|
|
|
170
182
|
if (html === last) {
|
|
171
183
|
options.chars && options.chars(html)
|
|
172
|
-
if (
|
|
173
|
-
options.warn(`Mal-formatted tag at end of template: "${html}"`, {
|
|
184
|
+
if (__DEV__ && !stack.length && options.warn) {
|
|
185
|
+
options.warn(`Mal-formatted tag at end of template: "${html}"`, {
|
|
186
|
+
start: index + html.length
|
|
187
|
+
})
|
|
174
188
|
}
|
|
175
189
|
break
|
|
176
190
|
}
|
|
@@ -179,22 +193,25 @@ export function parseHTML (html, options) {
|
|
|
179
193
|
// Clean up any remaining tags
|
|
180
194
|
parseEndTag()
|
|
181
195
|
|
|
182
|
-
function advance
|
|
196
|
+
function advance(n) {
|
|
183
197
|
index += n
|
|
184
198
|
html = html.substring(n)
|
|
185
199
|
}
|
|
186
200
|
|
|
187
|
-
function parseStartTag
|
|
201
|
+
function parseStartTag() {
|
|
188
202
|
const start = html.match(startTagOpen)
|
|
189
203
|
if (start) {
|
|
190
|
-
const match = {
|
|
204
|
+
const match: any = {
|
|
191
205
|
tagName: start[1],
|
|
192
206
|
attrs: [],
|
|
193
207
|
start: index
|
|
194
208
|
}
|
|
195
209
|
advance(start[0].length)
|
|
196
210
|
let end, attr
|
|
197
|
-
while (
|
|
211
|
+
while (
|
|
212
|
+
!(end = html.match(startTagClose)) &&
|
|
213
|
+
(attr = html.match(dynamicArgAttribute) || html.match(attribute))
|
|
214
|
+
) {
|
|
198
215
|
attr.start = index
|
|
199
216
|
advance(attr[0].length)
|
|
200
217
|
attr.end = index
|
|
@@ -209,7 +226,7 @@ export function parseHTML (html, options) {
|
|
|
209
226
|
}
|
|
210
227
|
}
|
|
211
228
|
|
|
212
|
-
function handleStartTag
|
|
229
|
+
function handleStartTag(match) {
|
|
213
230
|
const tagName = match.tagName
|
|
214
231
|
const unarySlash = match.unarySlash
|
|
215
232
|
|
|
@@ -229,21 +246,28 @@ export function parseHTML (html, options) {
|
|
|
229
246
|
for (let i = 0; i < l; i++) {
|
|
230
247
|
const args = match.attrs[i]
|
|
231
248
|
const value = args[3] || args[4] || args[5] || ''
|
|
232
|
-
const shouldDecodeNewlines =
|
|
233
|
-
|
|
234
|
-
|
|
249
|
+
const shouldDecodeNewlines =
|
|
250
|
+
tagName === 'a' && args[1] === 'href'
|
|
251
|
+
? options.shouldDecodeNewlinesForHref
|
|
252
|
+
: options.shouldDecodeNewlines
|
|
235
253
|
attrs[i] = {
|
|
236
254
|
name: args[1],
|
|
237
255
|
value: decodeAttr(value, shouldDecodeNewlines)
|
|
238
256
|
}
|
|
239
|
-
if (
|
|
257
|
+
if (__DEV__ && options.outputSourceRange) {
|
|
240
258
|
attrs[i].start = args.start + args[0].match(/^\s*/).length
|
|
241
259
|
attrs[i].end = args.end
|
|
242
260
|
}
|
|
243
261
|
}
|
|
244
262
|
|
|
245
263
|
if (!unary) {
|
|
246
|
-
stack.push({
|
|
264
|
+
stack.push({
|
|
265
|
+
tag: tagName,
|
|
266
|
+
lowerCasedTag: tagName.toLowerCase(),
|
|
267
|
+
attrs: attrs,
|
|
268
|
+
start: match.start,
|
|
269
|
+
end: match.end
|
|
270
|
+
})
|
|
247
271
|
lastTag = tagName
|
|
248
272
|
}
|
|
249
273
|
|
|
@@ -252,7 +276,7 @@ export function parseHTML (html, options) {
|
|
|
252
276
|
}
|
|
253
277
|
}
|
|
254
278
|
|
|
255
|
-
function parseEndTag
|
|
279
|
+
function parseEndTag(tagName?: any, start?: any, end?: any) {
|
|
256
280
|
let pos, lowerCasedTagName
|
|
257
281
|
if (start == null) start = index
|
|
258
282
|
if (end == null) end = index
|
|
@@ -273,14 +297,11 @@ export function parseHTML (html, options) {
|
|
|
273
297
|
if (pos >= 0) {
|
|
274
298
|
// Close all the open elements, up the stack
|
|
275
299
|
for (let i = stack.length - 1; i >= pos; i--) {
|
|
276
|
-
if (
|
|
277
|
-
(i
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
`tag <${stack[i].tag}> has no matching end tag.`,
|
|
282
|
-
{ start: stack[i].start, end: stack[i].end }
|
|
283
|
-
)
|
|
300
|
+
if (__DEV__ && (i > pos || !tagName) && options.warn) {
|
|
301
|
+
options.warn(`tag <${stack[i].tag}> has no matching end tag.`, {
|
|
302
|
+
start: stack[i].start,
|
|
303
|
+
end: stack[i].end
|
|
304
|
+
})
|
|
284
305
|
}
|
|
285
306
|
if (options.end) {
|
|
286
307
|
options.end(stack[i].tag, start, end)
|