Skip to content

Commit 01db30f

Browse files
authored
fix(es/parser): Reset ctx for cond while parsing a stmt (#7232)
1 parent c06690e commit 01db30f

File tree

3 files changed

+1430
-1
lines changed

3 files changed

+1430
-1
lines changed

crates/swc_ecma_parser/src/parser/stmt.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ impl<'a, I: Tokens> Parser<I> {
101101
return self.handle_import_export(top_level, decorators);
102102
}
103103

104-
self.parse_stmt_internal(start, include_decl, top_level, decorators)
104+
let ctx = Context {
105+
will_expect_colon_for_cond: false,
106+
..self.ctx()
107+
};
108+
self.with_ctx(ctx)
109+
.parse_stmt_internal(start, include_decl, top_level, decorators)
105110
.map(From::from)
106111
}
107112

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
3+
export async function postProcessHTML(
4+
) {
5+
const postProcessors: Array<PostProcessorFunction> = [
6+
process.env.NEXT_RUNTIME !== 'edge' && inAmpMode
7+
? async (html: string) => {
8+
const optimizeAmp = require('./optimize-amp')
9+
.default as typeof import('./optimize-amp').default
10+
html = await optimizeAmp!(html, renderOpts.ampOptimizerConfig)
11+
if (!renderOpts.ampSkipValidation && renderOpts.ampValidator) {
12+
await renderOpts.ampValidator(html, pathname)
13+
}
14+
return html
15+
}
16+
: null,
17+
process.env.NEXT_RUNTIME !== 'edge' && renderOpts.optimizeFonts
18+
? async (html: string) => {
19+
const getFontDefinition = (url: string): string => {
20+
}
21+
}
22+
: null,
23+
process.env.NEXT_RUNTIME !== 'edge' && renderOpts.optimizeCss
24+
? async (html: string) => {
25+
}
26+
: null,
27+
inAmpMode || hybridAmp
28+
? (html: string) => {
29+
return html.replace(/&amp;amp=1/g, '&amp=1')
30+
}
31+
: null,
32+
].filter(nonNullable)
33+
34+
}

0 commit comments

Comments
 (0)