Skip to content

Commit

Permalink
fix: Fix Style transform stencil variable lookup (#3038)
Browse files Browse the repository at this point in the history
Fix variable lookups in Stencils during static style transformation.

[category:Infrastructure]
  • Loading branch information
NicholasBoll authored Nov 6, 2024
1 parent 6ed8303 commit 6cf5850
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions modules/styling-transform/lib/utils/handleCreateStencil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ function parseStyleBlock(
if (ts.isObjectLiteralExpression(property.initializer)) {
styleObj = parseObjectToStaticValue(property.initializer, {
...context,
nameScope: `${stencilName}.`,
nameScope: `${stencilName}.vars.`,
});
}

Expand All @@ -350,7 +350,7 @@ function parseStyleBlock(
if (returnNode) {
styleObj = parseObjectToStaticValue(returnNode, {
...context,
nameScope: `${stencilName}.`,
nameScope: `${stencilName}.vars.`,
});
}
}
Expand All @@ -361,7 +361,7 @@ function parseStyleBlock(
if (returnNode) {
styleObj = parseObjectToStaticValue(returnNode, {
...context,
nameScope: `${stencilName}.`,
nameScope: `${stencilName}.vars.`,
});
}
}
Expand Down
8 changes: 4 additions & 4 deletions modules/styling-transform/lib/utils/parseNodeToStaticValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,13 @@ export function getValueFromAliasedSymbol(
function getValueFromProcessedNodes(varName: string, context: TransformerContext): string | void {
const {names} = context;

if (names[varName]) {
return names[varName];
}

if (context.nameScope && names[`${context.nameScope}${varName}`]) {
return names[`${context.nameScope}${varName}`];
}

if (names[varName]) {
return names[varName];
}
}

function hasExpression(node: ts.Node): node is ts.Node & {initializer: ts.Expression} {
Expand Down

0 comments on commit 6cf5850

Please sign in to comment.