Skip to content

Commit

Permalink
refacotor: refactor code & change to generate snapshots for the const…
Browse files Browse the repository at this point in the history
…ruct-tree test (#23)

* Revert "feat: implement templateRanges option (#22)"

This reverts commit 2538b1e.

* refactor: remove unused codes

* refactor: remove unused codes

* refactor: implement Pointer

* refactor

* refactor

* refactor
  • Loading branch information
yeonjuan authored Nov 29, 2024
1 parent 2538b1e commit f3d474e
Show file tree
Hide file tree
Showing 131 changed files with 8,547 additions and 8,841 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ coverage
dist
.yarn/*
!.yarn/releases
.DS_store
tsconfig.build.tsbuildinfo
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ interface ScriptTagNode extends BaseNode {
openStart: OpenScriptTagStartNode;
openEnd: OpenScriptTagEndNode;
close: CloseScriptTagNode;
children: ScriptTagContentNode[];
value?: ScriptTagContentNode;
}
```

Expand Down Expand Up @@ -529,7 +529,7 @@ interface StyleTagNode extends BaseNode {
openStart: OpenStyleTagStartNode;
openEnd: OpenStyleTagEndNode;
close: CloseStyleTagNode;
children: StyleTagContentNode[];
value?: StyleTagContentNode;
}
```

Expand Down Expand Up @@ -586,7 +586,7 @@ interface CommentNode extends BaseNode {
type: "Comment";
open: CommentOpenNode;
close: CommentCloseNode;
children: CommentContentNode[];
value: CommentContentNode;
}
```

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@typescript-eslint/parser": "^6.1.0",
"eslint": "^8.23.0",
"jest": "^29.6.1",
"jest-file-snapshot": "0.7.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
Expand Down
4 changes: 0 additions & 4 deletions src/parser/__tests__/__snapshots__/token-adapter.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ exports[`parse basic 1`] = `
"attributes": [],
"children": [
{
"isTemplate": false,
"loc": {
"end": {
"column": 12,
Expand Down Expand Up @@ -154,7 +153,6 @@ exports[`parse basic 1`] = `
"value": ">",
},
{
"isTemplate": false,
"loc": {
"end": {
"column": 12,
Expand Down Expand Up @@ -202,7 +200,6 @@ exports[`parse token adapter 1`] = `
"attributes": [],
"children": [
{
"isTemplate": false,
"loc": {
"end": {
"column": 12,
Expand Down Expand Up @@ -348,7 +345,6 @@ exports[`parse token adapter 1`] = `
"value": ">",
},
{
"isTemplate": false,
"loc": {
"end": {
"column": 12,
Expand Down
3 changes: 1 addition & 2 deletions src/parser/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import { Options } from "../types/parse";

export function parse(html: string, options?: Options): ParseResult {
const tokenAdapter = (options && options.tokenAdapter) || defaultTokenAdapter;
const templateRanges = (options && options.templateRanges) || [];
const { tokens } = tokenize(html, tokenAdapter, templateRanges);
const { tokens } = tokenize(html, tokenAdapter);
const { ast } = constructTree(tokens, undefined);
return {
ast: clearParent(ast),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

16 changes: 0 additions & 16 deletions src/tokenizer/__tests__/__output__/attributes-apostrophe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export default [
{
type: TokenTypes.Text,
value: "\n ",
isTemplate: false,
range: [5, 8],
loc: {
start: {
Expand Down Expand Up @@ -65,7 +64,6 @@ export default [
{
type: TokenTypes.AttributeKey,
value: "class",
isTemplate: false,
range: [14, 19],
loc: {
start: {
Expand Down Expand Up @@ -110,7 +108,6 @@ export default [
},
{
type: TokenTypes.AttributeValue,
isTemplate: false,
value: "test class",
range: [21, 31],
loc: {
Expand Down Expand Up @@ -141,7 +138,6 @@ export default [
},
{
type: TokenTypes.AttributeKey,
isTemplate: false,
value: "data-test",
range: [33, 42],
loc: {
Expand Down Expand Up @@ -187,7 +183,6 @@ export default [
},
{
type: TokenTypes.AttributeValue,
isTemplate: false,
value: "data<test>",
range: [44, 54],
loc: {
Expand Down Expand Up @@ -233,7 +228,6 @@ export default [
},
{
type: TokenTypes.Text,
isTemplate: false,
value: "\n some text\n\n ",
range: [56, 76],
loc: {
Expand Down Expand Up @@ -279,7 +273,6 @@ export default [
},
{
type: TokenTypes.Text,
isTemplate: false,
value: "\n another text\n\n ",
range: [81, 108],
loc: {
Expand Down Expand Up @@ -310,7 +303,6 @@ export default [
},
{
type: TokenTypes.AttributeKey,
isTemplate: false,
value: "custom-attr",
range: [132, 143],
loc: {
Expand Down Expand Up @@ -356,7 +348,6 @@ export default [
},
{
type: TokenTypes.AttributeValue,
isTemplate: false,
value: "custom >test",
range: [145, 157],
loc: {
Expand Down Expand Up @@ -387,7 +378,6 @@ export default [
},
{
type: TokenTypes.AttributeKey,
isTemplate: false,
value: "with-spaces",
range: [167, 178],
loc: {
Expand Down Expand Up @@ -433,7 +423,6 @@ export default [
},
{
type: TokenTypes.AttributeValue,
isTemplate: false,
value: "spaces test",
range: [185, 196],
loc: {
Expand Down Expand Up @@ -479,7 +468,6 @@ export default [
},
{
type: TokenTypes.Text,
isTemplate: false,
value: "\n custom element\n text\n ",
range: [205, 248],
loc: {
Expand Down Expand Up @@ -510,7 +498,6 @@ export default [
},
{
type: TokenTypes.Text,
isTemplate: false,
value: "\n ",
range: [265, 270],
loc: {
Expand Down Expand Up @@ -541,7 +528,6 @@ export default [
},
{
type: TokenTypes.Text,
isTemplate: false,
value: "\n ",
range: [276, 279],
loc: {
Expand Down Expand Up @@ -573,7 +559,6 @@ export default [
{
type: TokenTypes.Text,
value: "\n",
isTemplate: false,
range: [286, 287],
loc: {
start: {
Expand Down Expand Up @@ -603,7 +588,6 @@ export default [
},
{
type: TokenTypes.Text,
isTemplate: false,
value: "\n",
range: [293, 294],
loc: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default [
},
{
type: TokenTypes.AttributeKey,
isTemplate: false,
value: "target",
range: [3, 9],
loc: {
Expand Down Expand Up @@ -49,7 +48,6 @@ export default [
},
{
type: TokenTypes.AttributeValue,
isTemplate: false,
value: "”_blank”",
range: [10, 18],
loc: {
Expand Down
15 changes: 0 additions & 15 deletions src/tokenizer/__tests__/__output__/attributes-bare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default [
},
{
type: TokenTypes.AttributeKey,
isTemplate: false,
value: "key",
range: [5, 8],
loc: {
Expand Down Expand Up @@ -49,7 +48,6 @@ export default [
},
{
type: TokenTypes.AttributeValue,
isTemplate: false,
value: "value",
range: [11, 16],
loc: {
Expand All @@ -65,7 +63,6 @@ export default [
},
{
type: TokenTypes.AttributeKey,
isTemplate: false,
value: "and-another",
range: [18, 29],
loc: {
Expand Down Expand Up @@ -96,7 +93,6 @@ export default [
},
{
type: TokenTypes.AttributeValue,
isTemplate: false,
value: "value",
range: [32, 37],
loc: {
Expand Down Expand Up @@ -142,7 +138,6 @@ export default [
},
{
type: TokenTypes.Text,
isTemplate: false,
value: "\n\n",
range: [44, 46],
loc: {
Expand Down Expand Up @@ -173,7 +168,6 @@ export default [
},
{
type: TokenTypes.AttributeKey,
isTemplate: false,
value: "some",
range: [52, 56],
loc: {
Expand Down Expand Up @@ -204,7 +198,6 @@ export default [
},
{
type: TokenTypes.AttributeValue,
isTemplate: false,
value: "custom-attribute",
range: [57, 73],
loc: {
Expand Down Expand Up @@ -235,7 +228,6 @@ export default [
},
{
type: TokenTypes.Text,
isTemplate: false,
value: "\n some text\n\n ",
range: [74, 90],
loc: {
Expand Down Expand Up @@ -266,7 +258,6 @@ export default [
},
{
type: TokenTypes.AttributeKey,
isTemplate: false,
value: "and",
range: [106, 109],
loc: {
Expand Down Expand Up @@ -297,7 +288,6 @@ export default [
},
{
type: TokenTypes.AttributeValue,
isTemplate: false,
value: "here",
range: [110, 114],
loc: {
Expand All @@ -313,7 +303,6 @@ export default [
},
{
type: TokenTypes.AttributeKey,
isTemplate: false,
value: "and-even",
range: [119, 127],
loc: {
Expand Down Expand Up @@ -344,7 +333,6 @@ export default [
},
{
type: TokenTypes.AttributeValue,
isTemplate: false,
value: "here",
range: [130, 134],
loc: {
Expand Down Expand Up @@ -375,7 +363,6 @@ export default [
},
{
type: TokenTypes.Text,
isTemplate: false,
value: "\n custom element\n text\n ",
range: [138, 169],
loc: {
Expand Down Expand Up @@ -406,7 +393,6 @@ export default [
},
{
type: TokenTypes.Text,
isTemplate: false,
value: "\n",
range: [186, 187],
loc: {
Expand Down Expand Up @@ -437,7 +423,6 @@ export default [
},
{
type: TokenTypes.Text,
isTemplate: false,
value: "\n",
range: [194, 195],
loc: {
Expand Down
Loading

0 comments on commit f3d474e

Please sign in to comment.