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,52 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { genStaticKeys } from 'shared/util'
|
|
4
|
-
import { createCompiler } from 'compiler/index'
|
|
5
|
-
|
|
6
|
-
import modules from './modules/index'
|
|
7
|
-
import directives from './directives/index'
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
isUnaryTag,
|
|
11
|
-
mustUseProp,
|
|
12
|
-
isReservedTag,
|
|
13
|
-
canBeLeftOpenTag,
|
|
14
|
-
getTagNamespace
|
|
15
|
-
} from '../util/element'
|
|
16
|
-
|
|
17
|
-
export const baseOptions: WeexCompilerOptions = {
|
|
18
|
-
modules,
|
|
19
|
-
directives,
|
|
20
|
-
isUnaryTag,
|
|
21
|
-
mustUseProp,
|
|
22
|
-
canBeLeftOpenTag,
|
|
23
|
-
isReservedTag,
|
|
24
|
-
getTagNamespace,
|
|
25
|
-
preserveWhitespace: false,
|
|
26
|
-
recyclable: false,
|
|
27
|
-
staticKeys: genStaticKeys(modules)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const compiler = createCompiler(baseOptions)
|
|
31
|
-
|
|
32
|
-
export function compile (
|
|
33
|
-
template: string,
|
|
34
|
-
options?: WeexCompilerOptions
|
|
35
|
-
): WeexCompiledResult {
|
|
36
|
-
let generateAltRender = false
|
|
37
|
-
if (options && options.recyclable === true) {
|
|
38
|
-
generateAltRender = true
|
|
39
|
-
options.recyclable = false
|
|
40
|
-
}
|
|
41
|
-
const result = compiler.compile(template, options)
|
|
42
|
-
|
|
43
|
-
// generate @render function for <recycle-list>
|
|
44
|
-
if (options && generateAltRender) {
|
|
45
|
-
options.recyclable = true
|
|
46
|
-
// disable static optimizations
|
|
47
|
-
options.optimize = false
|
|
48
|
-
const { render } = compiler.compile(template, options)
|
|
49
|
-
result['@render'] = render
|
|
50
|
-
}
|
|
51
|
-
return result
|
|
52
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { makeMap } from 'shared/util'
|
|
4
|
-
|
|
5
|
-
// The "unitary tag" means that the tag node and its children
|
|
6
|
-
// must be sent to the native together.
|
|
7
|
-
const isUnitaryTag = makeMap('cell,header,cell-slot,recycle-list', true)
|
|
8
|
-
|
|
9
|
-
function preTransformNode (el: ASTElement) {
|
|
10
|
-
if (isUnitaryTag(el.tag) && !el.attrsList.some(item => item.name === 'append')) {
|
|
11
|
-
el.attrsMap.append = 'tree'
|
|
12
|
-
el.attrsList.push({ name: 'append', value: 'tree' })
|
|
13
|
-
}
|
|
14
|
-
if (el.attrsMap.append === 'tree') {
|
|
15
|
-
el.appendAsTree = true
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function genData (el: ASTElement): string {
|
|
20
|
-
return el.appendAsTree ? `appendAsTree:true,` : ''
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default {
|
|
24
|
-
staticKeys: ['appendAsTree'],
|
|
25
|
-
preTransformNode,
|
|
26
|
-
genData
|
|
27
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { parseText } from 'compiler/parser/text-parser'
|
|
4
|
-
import {
|
|
5
|
-
getAndRemoveAttr,
|
|
6
|
-
getBindingAttr,
|
|
7
|
-
baseWarn
|
|
8
|
-
} from 'compiler/helpers'
|
|
9
|
-
|
|
10
|
-
type StaticClassResult = {
|
|
11
|
-
dynamic: boolean,
|
|
12
|
-
classResult: string
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function transformNode (el: ASTElement, options: CompilerOptions) {
|
|
16
|
-
const warn = options.warn || baseWarn
|
|
17
|
-
const staticClass = getAndRemoveAttr(el, 'class')
|
|
18
|
-
const { dynamic, classResult } = parseStaticClass(staticClass, options)
|
|
19
|
-
if (process.env.NODE_ENV !== 'production' && dynamic && staticClass) {
|
|
20
|
-
warn(
|
|
21
|
-
`class="${staticClass}": ` +
|
|
22
|
-
'Interpolation inside attributes has been deprecated. ' +
|
|
23
|
-
'Use v-bind or the colon shorthand instead.',
|
|
24
|
-
el.rawAttrsMap['class']
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
if (!dynamic && classResult) {
|
|
28
|
-
el.staticClass = classResult
|
|
29
|
-
}
|
|
30
|
-
const classBinding = getBindingAttr(el, 'class', false /* getStatic */)
|
|
31
|
-
if (classBinding) {
|
|
32
|
-
el.classBinding = classBinding
|
|
33
|
-
} else if (dynamic) {
|
|
34
|
-
el.classBinding = classResult
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function genData (el: ASTElement): string {
|
|
39
|
-
let data = ''
|
|
40
|
-
if (el.staticClass) {
|
|
41
|
-
data += `staticClass:${el.staticClass},`
|
|
42
|
-
}
|
|
43
|
-
if (el.classBinding) {
|
|
44
|
-
data += `class:${el.classBinding},`
|
|
45
|
-
}
|
|
46
|
-
return data
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function parseStaticClass (staticClass: ?string, options: CompilerOptions): StaticClassResult {
|
|
50
|
-
// "a b c" -> ["a", "b", "c"] => staticClass: ["a", "b", "c"]
|
|
51
|
-
// "a {{x}} c" -> ["a", x, "c"] => classBinding: '["a", x, "c"]'
|
|
52
|
-
let dynamic = false
|
|
53
|
-
let classResult = ''
|
|
54
|
-
if (staticClass) {
|
|
55
|
-
const classList = staticClass.trim().split(' ').map(name => {
|
|
56
|
-
const result = parseText(name, options.delimiters)
|
|
57
|
-
if (result) {
|
|
58
|
-
dynamic = true
|
|
59
|
-
return result.expression
|
|
60
|
-
}
|
|
61
|
-
return JSON.stringify(name)
|
|
62
|
-
})
|
|
63
|
-
if (classList.length) {
|
|
64
|
-
classResult = '[' + classList.join(',') + ']'
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return { dynamic, classResult }
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default {
|
|
71
|
-
staticKeys: ['staticClass'],
|
|
72
|
-
transformNode,
|
|
73
|
-
genData
|
|
74
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { cached, camelize } from 'shared/util'
|
|
4
|
-
|
|
5
|
-
const normalize = cached(camelize)
|
|
6
|
-
|
|
7
|
-
function normalizeKeyName (str: string): string {
|
|
8
|
-
if (str.match(/^v\-/)) {
|
|
9
|
-
return str.replace(/(v-[a-z\-]+\:)([a-z\-]+)$/i, ($, directive, prop) => {
|
|
10
|
-
return directive + normalize(prop)
|
|
11
|
-
})
|
|
12
|
-
}
|
|
13
|
-
return normalize(str)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function transformNode (el: ASTElement) {
|
|
17
|
-
if (Array.isArray(el.attrsList)) {
|
|
18
|
-
el.attrsList.forEach(attr => {
|
|
19
|
-
if (attr.name && attr.name.match(/\-/)) {
|
|
20
|
-
const realName = normalizeKeyName(attr.name)
|
|
21
|
-
if (el.attrsMap) {
|
|
22
|
-
el.attrsMap[realName] = el.attrsMap[attr.name]
|
|
23
|
-
delete el.attrsMap[attr.name]
|
|
24
|
-
}
|
|
25
|
-
if (el.rawAttrsMap && el.rawAttrsMap[attr.name]) {
|
|
26
|
-
el.rawAttrsMap[realName] = el.rawAttrsMap[attr.name]
|
|
27
|
-
// $flow-disable-line
|
|
28
|
-
delete el.rawAttrsMap[attr.name]
|
|
29
|
-
}
|
|
30
|
-
attr.name = realName
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export default {
|
|
36
|
-
transformNode
|
|
37
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { addAttr } from 'compiler/helpers'
|
|
4
|
-
|
|
5
|
-
// mark component root nodes as
|
|
6
|
-
export function postTransformComponentRoot (el: ASTElement) {
|
|
7
|
-
if (!el.parent) {
|
|
8
|
-
// component root
|
|
9
|
-
addAttr(el, '@isComponentRoot', 'true')
|
|
10
|
-
addAttr(el, '@templateId', '_uid')
|
|
11
|
-
addAttr(el, '@componentProps', '$props || {}')
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { addAttr } from 'compiler/helpers'
|
|
4
|
-
import { RECYCLE_LIST_MARKER } from 'weex/util/index'
|
|
5
|
-
|
|
6
|
-
// mark components as inside recycle-list so that we know we need to invoke
|
|
7
|
-
// their special @render function instead of render in create-component.js
|
|
8
|
-
export function postTransformComponent (
|
|
9
|
-
el: ASTElement,
|
|
10
|
-
options: WeexCompilerOptions
|
|
11
|
-
) {
|
|
12
|
-
// $flow-disable-line (we know isReservedTag is there)
|
|
13
|
-
if (!options.isReservedTag(el.tag) && el.tag !== 'cell-slot') {
|
|
14
|
-
addAttr(el, RECYCLE_LIST_MARKER, 'true')
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { preTransformRecycleList } from './recycle-list'
|
|
4
|
-
import { postTransformComponent } from './component'
|
|
5
|
-
import { postTransformComponentRoot } from './component-root'
|
|
6
|
-
import { postTransformText } from './text'
|
|
7
|
-
import { preTransformVBind } from './v-bind'
|
|
8
|
-
import { preTransformVIf } from './v-if'
|
|
9
|
-
import { preTransformVFor } from './v-for'
|
|
10
|
-
import { postTransformVOn } from './v-on'
|
|
11
|
-
import { preTransformVOnce } from './v-once'
|
|
12
|
-
|
|
13
|
-
let currentRecycleList = null
|
|
14
|
-
|
|
15
|
-
function shouldCompile (el: ASTElement, options: WeexCompilerOptions) {
|
|
16
|
-
return options.recyclable ||
|
|
17
|
-
(currentRecycleList && el !== currentRecycleList)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function preTransformNode (el: ASTElement, options: WeexCompilerOptions) {
|
|
21
|
-
if (el.tag === 'recycle-list') {
|
|
22
|
-
preTransformRecycleList(el, options)
|
|
23
|
-
currentRecycleList = el
|
|
24
|
-
}
|
|
25
|
-
if (shouldCompile(el, options)) {
|
|
26
|
-
preTransformVBind(el)
|
|
27
|
-
preTransformVIf(el, options) // also v-else-if and v-else
|
|
28
|
-
preTransformVFor(el, options)
|
|
29
|
-
preTransformVOnce(el)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function transformNode (el: ASTElement, options: WeexCompilerOptions) {
|
|
34
|
-
if (shouldCompile(el, options)) {
|
|
35
|
-
// do nothing yet
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function postTransformNode (el: ASTElement, options: WeexCompilerOptions) {
|
|
40
|
-
if (shouldCompile(el, options)) {
|
|
41
|
-
// mark child component in parent template
|
|
42
|
-
postTransformComponent(el, options)
|
|
43
|
-
// mark root in child component template
|
|
44
|
-
postTransformComponentRoot(el)
|
|
45
|
-
// <text>: transform children text into value attr
|
|
46
|
-
if (el.tag === 'text') {
|
|
47
|
-
postTransformText(el)
|
|
48
|
-
}
|
|
49
|
-
postTransformVOn(el)
|
|
50
|
-
}
|
|
51
|
-
if (el === currentRecycleList) {
|
|
52
|
-
currentRecycleList = null
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export default {
|
|
57
|
-
preTransformNode,
|
|
58
|
-
transformNode,
|
|
59
|
-
postTransformNode
|
|
60
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { parseFor } from 'compiler/parser/index'
|
|
4
|
-
import { getAndRemoveAttr, addRawAttr } from 'compiler/helpers'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Map the following syntax to corresponding attrs:
|
|
8
|
-
*
|
|
9
|
-
* <recycle-list for="(item, i) in longList" switch="cellType">
|
|
10
|
-
* <cell-slot case="A"> ... </cell-slot>
|
|
11
|
-
* <cell-slot case="B"> ... </cell-slot>
|
|
12
|
-
* </recycle-list>
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
export function preTransformRecycleList (
|
|
16
|
-
el: ASTElement,
|
|
17
|
-
options: WeexCompilerOptions
|
|
18
|
-
) {
|
|
19
|
-
const exp = getAndRemoveAttr(el, 'for')
|
|
20
|
-
if (!exp) {
|
|
21
|
-
if (options.warn) {
|
|
22
|
-
options.warn(`Invalid <recycle-list> syntax: missing "for" expression.`)
|
|
23
|
-
}
|
|
24
|
-
return
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const res = parseFor(exp)
|
|
28
|
-
if (!res) {
|
|
29
|
-
if (options.warn) {
|
|
30
|
-
options.warn(`Invalid <recycle-list> syntax: ${exp}.`)
|
|
31
|
-
}
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
addRawAttr(el, ':list-data', res.for)
|
|
36
|
-
addRawAttr(el, 'binding-expression', res.for)
|
|
37
|
-
addRawAttr(el, 'alias', res.alias)
|
|
38
|
-
if (res.iterator2) {
|
|
39
|
-
// (item, key, index) for object iteration
|
|
40
|
-
// is this even supported?
|
|
41
|
-
addRawAttr(el, 'index', res.iterator2)
|
|
42
|
-
} else if (res.iterator1) {
|
|
43
|
-
addRawAttr(el, 'index', res.iterator1)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const switchKey = getAndRemoveAttr(el, 'switch')
|
|
47
|
-
if (switchKey) {
|
|
48
|
-
addRawAttr(el, 'switch', switchKey)
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { addAttr } from 'compiler/helpers'
|
|
4
|
-
|
|
5
|
-
function genText (node: ASTNode) {
|
|
6
|
-
const value = node.type === 3
|
|
7
|
-
? node.text
|
|
8
|
-
: node.type === 2
|
|
9
|
-
? node.tokens.length === 1
|
|
10
|
-
? node.tokens[0]
|
|
11
|
-
: node.tokens
|
|
12
|
-
: ''
|
|
13
|
-
return JSON.stringify(value)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function postTransformText (el: ASTElement) {
|
|
17
|
-
// weex <text> can only contain text, so the parser
|
|
18
|
-
// always generates a single child.
|
|
19
|
-
if (el.children.length) {
|
|
20
|
-
addAttr(el, 'value', genText(el.children[0]))
|
|
21
|
-
el.children = []
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { camelize } from 'shared/util'
|
|
4
|
-
import { generateBinding } from 'weex/util/parser'
|
|
5
|
-
import { bindRE } from 'compiler/parser/index'
|
|
6
|
-
import { getAndRemoveAttr, addRawAttr } from 'compiler/helpers'
|
|
7
|
-
|
|
8
|
-
function parseAttrName (name: string): string {
|
|
9
|
-
return camelize(name.replace(bindRE, ''))
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function preTransformVBind (el: ASTElement) {
|
|
13
|
-
for (const attr in el.attrsMap) {
|
|
14
|
-
if (bindRE.test(attr)) {
|
|
15
|
-
const name: string = parseAttrName(attr)
|
|
16
|
-
const value = generateBinding(getAndRemoveAttr(el, attr))
|
|
17
|
-
delete el.attrsMap[attr]
|
|
18
|
-
addRawAttr(el, name, value)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { parseFor } from 'compiler/parser/index'
|
|
4
|
-
import { getAndRemoveAttr, addRawAttr } from 'compiler/helpers'
|
|
5
|
-
|
|
6
|
-
export function preTransformVFor (el: ASTElement, options: WeexCompilerOptions) {
|
|
7
|
-
const exp = getAndRemoveAttr(el, 'v-for')
|
|
8
|
-
if (!exp) {
|
|
9
|
-
return
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const res = parseFor(exp)
|
|
13
|
-
if (!res) {
|
|
14
|
-
if (process.env.NODE_ENV !== 'production' && options.warn) {
|
|
15
|
-
options.warn(`Invalid v-for expression: ${exp}`)
|
|
16
|
-
}
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const desc: Object = {
|
|
21
|
-
'@expression': res.for,
|
|
22
|
-
'@alias': res.alias
|
|
23
|
-
}
|
|
24
|
-
if (res.iterator2) {
|
|
25
|
-
desc['@key'] = res.iterator1
|
|
26
|
-
desc['@index'] = res.iterator2
|
|
27
|
-
} else {
|
|
28
|
-
desc['@index'] = res.iterator1
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
delete el.attrsMap['v-for']
|
|
32
|
-
addRawAttr(el, '[[repeat]]', desc)
|
|
33
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { addIfCondition } from 'compiler/parser/index'
|
|
4
|
-
import { getAndRemoveAttr, addRawAttr } from 'compiler/helpers'
|
|
5
|
-
|
|
6
|
-
function hasConditionDirective (el: ASTElement): boolean {
|
|
7
|
-
for (const attr in el.attrsMap) {
|
|
8
|
-
if (/^v\-if|v\-else|v\-else\-if$/.test(attr)) {
|
|
9
|
-
return true
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return false
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function getPreviousConditions (el: ASTElement): Array<string> {
|
|
16
|
-
const conditions = []
|
|
17
|
-
if (el.parent && el.parent.children) {
|
|
18
|
-
for (let c = 0, n = el.parent.children.length; c < n; ++c) {
|
|
19
|
-
// $flow-disable-line
|
|
20
|
-
const ifConditions = el.parent.children[c].ifConditions
|
|
21
|
-
if (ifConditions) {
|
|
22
|
-
for (let i = 0, l = ifConditions.length; i < l; ++i) {
|
|
23
|
-
const condition = ifConditions[i]
|
|
24
|
-
if (condition && condition.exp) {
|
|
25
|
-
conditions.push(condition.exp)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return conditions
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function preTransformVIf (el: ASTElement, options: WeexCompilerOptions) {
|
|
35
|
-
if (hasConditionDirective(el)) {
|
|
36
|
-
let exp
|
|
37
|
-
const ifExp = getAndRemoveAttr(el, 'v-if', true /* remove from attrsMap */)
|
|
38
|
-
const elseifExp = getAndRemoveAttr(el, 'v-else-if', true)
|
|
39
|
-
// don't need the value, but remove it to avoid being generated as a
|
|
40
|
-
// custom directive
|
|
41
|
-
getAndRemoveAttr(el, 'v-else', true)
|
|
42
|
-
if (ifExp) {
|
|
43
|
-
exp = ifExp
|
|
44
|
-
addIfCondition(el, { exp: ifExp, block: el })
|
|
45
|
-
} else {
|
|
46
|
-
elseifExp && addIfCondition(el, { exp: elseifExp, block: el })
|
|
47
|
-
const prevConditions = getPreviousConditions(el)
|
|
48
|
-
if (prevConditions.length) {
|
|
49
|
-
const prevMatch = prevConditions.join(' || ')
|
|
50
|
-
exp = elseifExp
|
|
51
|
-
? `!(${prevMatch}) && (${elseifExp})` // v-else-if
|
|
52
|
-
: `!(${prevMatch})` // v-else
|
|
53
|
-
} else if (process.env.NODE_ENV !== 'production' && options.warn) {
|
|
54
|
-
options.warn(
|
|
55
|
-
`v-${elseifExp ? ('else-if="' + elseifExp + '"') : 'else'} ` +
|
|
56
|
-
`used on element <${el.tag}> without corresponding v-if.`
|
|
57
|
-
)
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
addRawAttr(el, '[[match]]', exp)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
const inlineStatementRE = /^\s*([A-Za-z_$0-9\['\."\]]+)*\s*\(\s*(([A-Za-z_$0-9\['\."\]]+)?(\s*,\s*([A-Za-z_$0-9\['\."\]]+))*)\s*\)$/
|
|
4
|
-
|
|
5
|
-
function parseHandlerParams (handler: ASTElementHandler) {
|
|
6
|
-
const res = inlineStatementRE.exec(handler.value)
|
|
7
|
-
if (res && res[2]) {
|
|
8
|
-
handler.params = res[2].split(/\s*,\s*/)
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function postTransformVOn (el: ASTElement) {
|
|
13
|
-
const events: ASTElementHandlers | void = el.events
|
|
14
|
-
if (!events) {
|
|
15
|
-
return
|
|
16
|
-
}
|
|
17
|
-
for (const name in events) {
|
|
18
|
-
const handler: ASTElementHandler | Array<ASTElementHandler> = events[name]
|
|
19
|
-
if (Array.isArray(handler)) {
|
|
20
|
-
handler.map(fn => parseHandlerParams(fn))
|
|
21
|
-
} else {
|
|
22
|
-
parseHandlerParams(handler)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { getAndRemoveAttr, addRawAttr } from 'compiler/helpers'
|
|
4
|
-
|
|
5
|
-
function containVOnce (el: ASTElement): boolean {
|
|
6
|
-
for (const attr in el.attrsMap) {
|
|
7
|
-
if (/^v\-once$/i.test(attr)) {
|
|
8
|
-
return true
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return false
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function preTransformVOnce (el: ASTElement) {
|
|
15
|
-
if (containVOnce(el)) {
|
|
16
|
-
getAndRemoveAttr(el, 'v-once', true)
|
|
17
|
-
addRawAttr(el, '[[once]]', true)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
import { cached, camelize, isPlainObject } from 'shared/util'
|
|
4
|
-
import { parseText } from 'compiler/parser/text-parser'
|
|
5
|
-
import {
|
|
6
|
-
getAndRemoveAttr,
|
|
7
|
-
getBindingAttr,
|
|
8
|
-
baseWarn
|
|
9
|
-
} from 'compiler/helpers'
|
|
10
|
-
|
|
11
|
-
type StaticStyleResult = {
|
|
12
|
-
dynamic: boolean,
|
|
13
|
-
styleResult: string | Object | void
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const normalize = cached(camelize)
|
|
17
|
-
|
|
18
|
-
function transformNode (el: ASTElement, options: CompilerOptions) {
|
|
19
|
-
const warn = options.warn || baseWarn
|
|
20
|
-
const staticStyle = getAndRemoveAttr(el, 'style')
|
|
21
|
-
const { dynamic, styleResult } = parseStaticStyle(staticStyle, options)
|
|
22
|
-
if (process.env.NODE_ENV !== 'production' && dynamic) {
|
|
23
|
-
warn(
|
|
24
|
-
`style="${String(staticStyle)}": ` +
|
|
25
|
-
'Interpolation inside attributes has been deprecated. ' +
|
|
26
|
-
'Use v-bind or the colon shorthand instead.',
|
|
27
|
-
el.rawAttrsMap['style']
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
if (!dynamic && styleResult) {
|
|
31
|
-
// $flow-disable-line
|
|
32
|
-
el.staticStyle = styleResult
|
|
33
|
-
}
|
|
34
|
-
const styleBinding = getBindingAttr(el, 'style', false /* getStatic */)
|
|
35
|
-
if (styleBinding) {
|
|
36
|
-
el.styleBinding = styleBinding
|
|
37
|
-
} else if (dynamic) {
|
|
38
|
-
// $flow-disable-line
|
|
39
|
-
el.styleBinding = styleResult
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function genData (el: ASTElement): string {
|
|
44
|
-
let data = ''
|
|
45
|
-
if (el.staticStyle) {
|
|
46
|
-
data += `staticStyle:${el.staticStyle},`
|
|
47
|
-
}
|
|
48
|
-
if (el.styleBinding) {
|
|
49
|
-
data += `style:${el.styleBinding},`
|
|
50
|
-
}
|
|
51
|
-
return data
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function parseStaticStyle (staticStyle: ?string, options: CompilerOptions): StaticStyleResult {
|
|
55
|
-
// "width: 200px; height: 200px;" -> {width: 200, height: 200}
|
|
56
|
-
// "width: 200px; height: {{y}}" -> {width: 200, height: y}
|
|
57
|
-
let dynamic = false
|
|
58
|
-
let styleResult = ''
|
|
59
|
-
if (typeof staticStyle === 'string') {
|
|
60
|
-
const styleList = staticStyle.trim().split(';').map(style => {
|
|
61
|
-
const result = style.trim().split(':')
|
|
62
|
-
if (result.length !== 2) {
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
const key = normalize(result[0].trim())
|
|
66
|
-
const value = result[1].trim()
|
|
67
|
-
const dynamicValue = parseText(value, options.delimiters)
|
|
68
|
-
if (dynamicValue) {
|
|
69
|
-
dynamic = true
|
|
70
|
-
return key + ':' + dynamicValue.expression
|
|
71
|
-
}
|
|
72
|
-
return key + ':' + JSON.stringify(value)
|
|
73
|
-
}).filter(result => result)
|
|
74
|
-
if (styleList.length) {
|
|
75
|
-
styleResult = '{' + styleList.join(',') + '}'
|
|
76
|
-
}
|
|
77
|
-
} else if (isPlainObject(staticStyle)) {
|
|
78
|
-
styleResult = JSON.stringify(staticStyle) || ''
|
|
79
|
-
}
|
|
80
|
-
return { dynamic, styleResult }
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export default {
|
|
84
|
-
staticKeys: ['staticStyle'],
|
|
85
|
-
transformNode,
|
|
86
|
-
genData
|
|
87
|
-
}
|