wip: filters compat

This commit is contained in:
Evan You
2021-04-19 12:08:26 -04:00
parent 467076361a
commit 7dc681c196
18 changed files with 349 additions and 41 deletions

View File

@@ -50,7 +50,8 @@ import {
CREATE_BLOCK,
OPEN_BLOCK,
CREATE_STATIC,
WITH_CTX
WITH_CTX,
RESOLVE_FILTER
} from './runtimeHelpers'
import { ImportItem } from './transform'
@@ -274,6 +275,12 @@ export function generate(
newline()
}
}
if (__COMPAT__ && ast.filters && ast.filters.length) {
newline()
genAssets(ast.filters, 'filter', context)
newline()
}
if (ast.temps > 0) {
push(`let `)
for (let i = 0; i < ast.temps; i++) {
@@ -458,11 +465,15 @@ function genModulePreamble(
function genAssets(
assets: string[],
type: 'component' | 'directive',
type: 'component' | 'directive' | 'filter',
{ helper, push, newline }: CodegenContext
) {
const resolver = helper(
type === 'component' ? RESOLVE_COMPONENT : RESOLVE_DIRECTIVE
__COMPAT__ && type === 'filter'
? RESOLVE_FILTER
: type === 'component'
? RESOLVE_COMPONENT
: RESOLVE_DIRECTIVE
)
for (let i = 0; i < assets.length; i++) {
let id = assets[i]