@tsrx/core 0.1.49 → 0.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/plugin.js +17 -13
package/package.json
CHANGED
package/src/plugin.js
CHANGED
|
@@ -3411,17 +3411,20 @@ export function TSRXPlugin(config) {
|
|
|
3411
3411
|
let node = /** @type {ESTreeJSX.JSXExpressionContainer} */ (this.startNode());
|
|
3412
3412
|
this.#jsxExpressionContainerDepth++;
|
|
3413
3413
|
let pushed_context_baseline = false;
|
|
3414
|
-
|
|
3415
|
-
|
|
3414
|
+
// The stack depth with the container's `{` brace context on top, taken
|
|
3415
|
+
// before `next()` so the first expression token's own context pushes
|
|
3416
|
+
// (e.g. a fragment's `<` pushing its tag contexts) are not counted.
|
|
3417
|
+
// This is the depth the stack must return to when the container's
|
|
3418
|
+
// closing `}` is the current token.
|
|
3419
|
+
const container_context_depth = this.context.length;
|
|
3416
3420
|
try {
|
|
3417
3421
|
this.next();
|
|
3418
3422
|
|
|
3419
|
-
// Record the context-stack depth now that the
|
|
3420
|
-
//
|
|
3423
|
+
// Record the context-stack depth now that the first expression token
|
|
3424
|
+
// has been read. A control-flow directive parsed inside this
|
|
3421
3425
|
// container must not strip anything below this floor (see
|
|
3422
3426
|
// `#filterTemplateScriptContexts`).
|
|
3423
|
-
|
|
3424
|
-
this.#expressionContainerContextBaselines.push(context_baseline);
|
|
3427
|
+
this.#expressionContainerContextBaselines.push(this.context.length);
|
|
3425
3428
|
this.#expressionContainerPathBaselines.push(this.#path.length);
|
|
3426
3429
|
pushed_context_baseline = true;
|
|
3427
3430
|
|
|
@@ -3442,13 +3445,14 @@ export function TSRXPlugin(config) {
|
|
|
3442
3445
|
// a snapshot taken inside this container
|
|
3443
3446
|
// (`#parseTemplateControlFlowBlock`), so the container's closing `}`
|
|
3444
3447
|
// — read while that stale snapshot was active — pops the wrong entry
|
|
3445
|
-
// and leaves stale
|
|
3446
|
-
//
|
|
3447
|
-
//
|
|
3448
|
-
//
|
|
3449
|
-
//
|
|
3450
|
-
|
|
3451
|
-
|
|
3448
|
+
// and leaves stale contexts above the enclosing tag's contexts (the
|
|
3449
|
+
// directive's statement brace, or a wrapping fragment's child
|
|
3450
|
+
// context). Once the `}` has been read the stack must be back at one
|
|
3451
|
+
// below the container's depth (its own brace context popped); drop
|
|
3452
|
+
// anything above that so the token after `}` (e.g. the `>` finishing
|
|
3453
|
+
// the enclosing opening tag) tokenizes in the right context.
|
|
3454
|
+
if (this.type === tt.braceR && this.context.length >= container_context_depth) {
|
|
3455
|
+
this.context.length = container_context_depth - 1;
|
|
3452
3456
|
}
|
|
3453
3457
|
this.expect(tt.braceR);
|
|
3454
3458
|
}
|