@vuedx/compiler-tsx
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -1,2 +0,2 @@ | ||
import { createSimpleExpression, createCompoundExpression, isSimpleIdentifier, buildSlots, createFunctionExpression, WITH_CTX, createStructuralDirectiveTransform, processFor, createCallExpression, RENDER_LIST, createForLoopParams, baseParse, transform, trackVForSlotScopes, OPEN_BLOCK, CREATE_BLOCK, CREATE_VNODE, FRAGMENT, generate } from '@vue/compiler-core'; | ||
import { createSimpleExpression, createCompoundExpression, isSimpleIdentifier, buildSlots, createFunctionExpression, WITH_CTX, findDir, createStructuralDirectiveTransform, processFor, createCallExpression, RENDER_LIST, createForLoopParams, baseParse, transform, OPEN_BLOCK, CREATE_BLOCK, CREATE_VNODE, FRAGMENT, generate } from '@vue/compiler-core'; | ||
import { isElementNode, isComponentNode, isAttributeNode, isSimpleExpressionNode, isTextNode, isIfNode, isForNode, isInterpolationNode, isDirectiveNode } from '@vuedx/template-ast-types'; | ||
@@ -113,5 +113,5 @@ import camelCase from 'lodash.camelcase'; | ||
if (isSimpleExpressionNode(dir.arg)) { | ||
if (dir.arg.isStatic) { | ||
if (dir.arg.isStatic || dir.arg.content === 'key') { | ||
dir.arg.isStatic = false; | ||
result.push(' ', dir.arg); | ||
result.push(' ', dir.arg.content === 'class' ? 'className' : dir.arg); | ||
if (dir.exp) | ||
@@ -233,2 +233,3 @@ result.push('={', dir.exp, '}'); | ||
return (node, context) => { | ||
const localIdentifiers = new Set(); | ||
if (isInterpolationNode(node)) { | ||
@@ -245,2 +246,11 @@ if (isSimpleExpressionNode(node.content) && !node.content.isStatic) { | ||
} | ||
const slot = findDir(node, 'slot'); | ||
if (slot) { | ||
if (isSimpleExpressionNode(slot.exp) && !slot.exp.isStatic) { | ||
trackIdentifiers(slot.exp.content, context, (identifier) => { | ||
localIdentifiers.add(identifier); | ||
context.addIdentifiers(identifier); | ||
}, dir.name === 'slot'); | ||
} | ||
} | ||
switch (dir.name) { | ||
@@ -256,5 +266,7 @@ case 'for': | ||
break; | ||
case 'slot': | ||
break; | ||
default: { | ||
if (isSimpleExpressionNode(dir.exp) && !dir.exp.isStatic) { | ||
trackIdentifiers(dir.exp.content, context, addIdentifer, dir.name === 'slot'); | ||
trackIdentifiers(dir.exp.content, context, addIdentifer); | ||
} | ||
@@ -266,2 +278,5 @@ } | ||
} | ||
return () => { | ||
localIdentifiers.forEach((identifier) => context.removeIdentifiers(identifier)); | ||
}; | ||
}; | ||
@@ -423,6 +438,5 @@ } | ||
}, | ||
createElementTransform(config), | ||
createTransformFor((id) => identifiers.add(id)), | ||
trackVForSlotScopes, | ||
createExpressionTracker((id) => identifiers.add(id)), | ||
createElementTransform(config), | ||
createInterpolationTransform(), | ||
@@ -429,0 +443,0 @@ ], |
@@ -119,5 +119,5 @@ 'use strict'; | ||
if (templateAstTypes.isSimpleExpressionNode(dir.arg)) { | ||
if (dir.arg.isStatic) { | ||
if (dir.arg.isStatic || dir.arg.content === 'key') { | ||
dir.arg.isStatic = false; | ||
result.push(' ', dir.arg); | ||
result.push(' ', dir.arg.content === 'class' ? 'className' : dir.arg); | ||
if (dir.exp) | ||
@@ -239,2 +239,3 @@ result.push('={', dir.exp, '}'); | ||
return (node, context) => { | ||
const localIdentifiers = new Set(); | ||
if (templateAstTypes.isInterpolationNode(node)) { | ||
@@ -251,2 +252,11 @@ if (templateAstTypes.isSimpleExpressionNode(node.content) && !node.content.isStatic) { | ||
} | ||
const slot = compilerCore.findDir(node, 'slot'); | ||
if (slot) { | ||
if (templateAstTypes.isSimpleExpressionNode(slot.exp) && !slot.exp.isStatic) { | ||
trackIdentifiers(slot.exp.content, context, (identifier) => { | ||
localIdentifiers.add(identifier); | ||
context.addIdentifiers(identifier); | ||
}, dir.name === 'slot'); | ||
} | ||
} | ||
switch (dir.name) { | ||
@@ -262,5 +272,7 @@ case 'for': | ||
break; | ||
case 'slot': | ||
break; | ||
default: { | ||
if (templateAstTypes.isSimpleExpressionNode(dir.exp) && !dir.exp.isStatic) { | ||
trackIdentifiers(dir.exp.content, context, addIdentifer, dir.name === 'slot'); | ||
trackIdentifiers(dir.exp.content, context, addIdentifer); | ||
} | ||
@@ -272,2 +284,5 @@ } | ||
} | ||
return () => { | ||
localIdentifiers.forEach((identifier) => context.removeIdentifiers(identifier)); | ||
}; | ||
}; | ||
@@ -429,6 +444,5 @@ } | ||
}, | ||
createElementTransform(config), | ||
createTransformFor((id) => identifiers.add(id)), | ||
compilerCore.trackVForSlotScopes, | ||
createExpressionTracker((id) => identifiers.add(id)), | ||
createElementTransform(config), | ||
createInterpolationTransform(), | ||
@@ -435,0 +449,0 @@ ], |
{ | ||
"name": "@vuedx/compiler-tsx", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "", | ||
@@ -18,3 +18,3 @@ "main": "dist/compiler-tsx.js", | ||
"@vue/compiler-core": "^3.0.0-rc.4", | ||
"@vuedx/template-ast-types": "0.1.3", | ||
"@vuedx/template-ast-types": "0.1.4", | ||
"lodash.camelcase": "^4.3.0" | ||
@@ -21,0 +21,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
121101
973
+ Added@vuedx/template-ast-types@0.1.4(transitive)
- Removed@vuedx/template-ast-types@0.1.3(transitive)