Skip to content

Commit

Permalink
Merge pull request #1284 from glimmerjs/fix-entity-parser-in-codemod-…
Browse files Browse the repository at this point in the history
…mode

Ensure Entities are never transformed in codemod mode.
  • Loading branch information
rwjblue authored Mar 16, 2021
2 parents 1bfe161 + b505629 commit ba469dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/@glimmer/syntax/lib/parser/tokenizer-event-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,17 @@ const syntax: Syntax = {
Walker,
};

class CodemodEntityParser extends EntityParser {
// match upstream types, but never match an entity
constructor() {
super({});
}

parse(): string | undefined {
return undefined;
}
}

export function preprocess(
input: string | Source | HBS.Program,
options: PreprocessOptions = {}
Expand Down Expand Up @@ -412,7 +423,7 @@ export function preprocess(

let entityParser = undefined;
if (mode === 'codemod') {
entityParser = new EntityParser({});
entityParser = new CodemodEntityParser();
}

let offsets = SourceSpan.forCharPositions(source, 0, source.source.length);
Expand Down
2 changes: 2 additions & 0 deletions packages/@glimmer/syntax/test/generation/print-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ QUnit.module('[glimmer-syntax] Code generation - source -> source', function ()

// "stand alone"
' {{#foo}}\n {{bar}}\n {{/foo}}',

`<span class="stampFont" style="font-family: 'stampfont'">&#xf000;</span>`,
].forEach(buildTest);
});

Expand Down

0 comments on commit ba469dd

Please sign in to comment.