( dir: DirectiveNode, context: TransformContext, )
| 873 | } |
| 874 | |
| 875 | export function buildDirectiveArgs( |
| 876 | dir: DirectiveNode, |
| 877 | context: TransformContext, |
| 878 | ): ArrayExpression { |
| 879 | const dirArgs: ArrayExpression['elements'] = [] |
| 880 | const runtime = directiveImportMap.get(dir) |
| 881 | if (runtime) { |
| 882 | // built-in directive with runtime |
| 883 | dirArgs.push(context.helperString(runtime)) |
| 884 | } else { |
| 885 | // user directive. |
| 886 | // see if we have directives exposed via <script setup> |
| 887 | const fromSetup = |
| 888 | !__BROWSER__ && resolveSetupReference('v-' + dir.name, context) |
| 889 | if (fromSetup) { |
| 890 | dirArgs.push(fromSetup) |
| 891 | } else { |
| 892 | // inject statement for resolving directive |
| 893 | context.helper(RESOLVE_DIRECTIVE) |
| 894 | context.directives.add(dir.name) |
| 895 | dirArgs.push(toValidAssetId(dir.name, `directive`)) |
| 896 | } |
| 897 | } |
| 898 | const { loc } = dir |
| 899 | if (dir.exp) dirArgs.push(dir.exp) |
| 900 | if (dir.arg) { |
| 901 | if (!dir.exp) { |
| 902 | dirArgs.push(`void 0`) |
| 903 | } |
| 904 | dirArgs.push(dir.arg) |
| 905 | } |
| 906 | if (Object.keys(dir.modifiers).length) { |
| 907 | if (!dir.arg) { |
| 908 | if (!dir.exp) { |
| 909 | dirArgs.push(`void 0`) |
| 910 | } |
| 911 | dirArgs.push(`void 0`) |
| 912 | } |
| 913 | const trueExpression = createSimpleExpression(`true`, false, loc) |
| 914 | dirArgs.push( |
| 915 | createObjectExpression( |
| 916 | dir.modifiers.map(modifier => |
| 917 | createObjectProperty(modifier, trueExpression), |
| 918 | ), |
| 919 | loc, |
| 920 | ), |
| 921 | ) |
| 922 | } |
| 923 | return createArrayExpression(dirArgs, dir.loc) |
| 924 | } |
| 925 | |
| 926 | function stringifyDynamicPropNames(props: string[]): string { |
| 927 | let propsNamesString = `[` |
no test coverage detected