Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/angular-html-parser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function parseXml(input: string) {

// For prettier
export { TagContentType } from "../../compiler/src/ml_parser/tags.ts";
export { TokenType } from "../../compiler/src/ml_parser/tokens.ts";
export {
RecursiveVisitor,
visitAll,
Expand All @@ -111,6 +112,7 @@ export { SUPPORTED_BLOCKS as SUPPORTED_ANGULAR_BLOCKS } from "../../compiler/src

// Types
export type { ParseTreeResult } from "../../compiler/src/ml_parser/parser.ts";
export type * as Tokens from "../../compiler/src/ml_parser/tokens.ts";
export type * as Ast from "../../compiler/src/ml_parser/ast.ts";

// Remove these alias in next major release
Expand Down
14 changes: 13 additions & 1 deletion packages/angular-html-parser/test/index_spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
import { parse, TagContentType } from "../src/index.ts";
import { parse, TagContentType, TokenType } from "../src/index.ts";
import { humanizeDom } from "../../compiler/test/ml_parser/ast_spec_utils.ts";
import * as ast from "../../compiler/src/ml_parser/ast.ts";

Expand Down Expand Up @@ -286,3 +286,15 @@ it("Edge cases", () => {
[ast.Element, ":html:style", 0],
]);
});

describe("public token API", () => {
it("should expose TokenType", () => {
const node = parse('{{ "}}" }}').rootNodes[0] as ast.Text;
expect(node).toBeInstanceOf(ast.Text);

const token = node.tokens.find(
({ type }) => type === TokenType.INTERPOLATION,
)!;
expect(token.parts).toEqual(["{{", ' "}}" ', "}}"]);
});
});
Loading