Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix alias bug #302

Merged
merged 1 commit into from
Aug 25, 2024
Merged

Fix alias bug #302

merged 1 commit into from
Aug 25, 2024

Conversation

drwpow
Copy link
Collaborator

@drwpow drwpow commented Aug 25, 2024

Changes

Fixes a bug in the aliasing. #299 was close, trying to catch the bug, but didn’t quite get it.

How to Review

  • Tests updated; tests should pass.

const { mode: aliasMode } = parseAlias(token.$value[i]);
token.partialAliasOf[i] = aliasOfID;
const { id: aliasID, mode: aliasMode } = parseAlias(token.$value[i]);
token.partialAliasOf[i] = aliasID;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reaallllly subtle bug: when using partialAliasOf, we want the immediate alias, not the resolved value. This can lead to incorrect values because you may set up different modes / different triggers for intermediary aliases.

Copy link

cloudflare-workers-and-pages bot commented Aug 25, 2024

Deploying terrazzo with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7365f95
Status: ✅  Deploy successful!
Preview URL: https://c6d4e115.terrazzo.pages.dev
Branch Preview URL: https://plugin-css-publish.terrazzo.pages.dev

View logs

}
const aliasOfID = resolveAlias(token.$value[i][property], { tokens, logger, filename, node, src });
const { mode: aliasMode } = parseAlias(token.$value[i][property]);
const { id: aliasID, mode: aliasMode } = parseAlias(token.$value[i][property]);
token.partialAliasOf[i][property] = aliasID; // also keep the shallow alias here, too!
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: I am actually a really big fan of having this parser stay in .js. At a microscopic level, sure, there are a few papercuts. But on a macro level, dealing with “incorrect” data structures and defensive programming are SOOOOO much easier in JS than TS (you basically have to turn types off anyway, because it thinks something can’t be a certain type, unless you type everything as unknown, at which point… why are you using TS?)

@drwpow drwpow merged commit d0a9df4 into main Aug 25, 2024
10 checks passed
@drwpow drwpow deleted the plugin-css-publish branch August 25, 2024 22:37
@github-actions github-actions bot mentioned this pull request Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant