-
-
Notifications
You must be signed in to change notification settings - Fork 71
chore: drop html deps #840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
31a7b71
chore: drop html deps
manuel3108 7b0baad
fix duplicate lang attribute
manuel3108 972ce22
fix
manuel3108 5466cc6
Merge remote-tracking branch 'origin/main' into chore/drop-deps-html
manuel3108 e96772d
bump to svelte 5.45.9
jycouet a918b66
now the test is passing 🎉
jycouet 443b118
ts is better now
jycouet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/sv/lib/core/tests/html/common/add-attribute/input.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| <div></div> |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { addAttribute, type SvelteAst } from '../../../../tooling/html/index.ts'; | ||
|
|
||
| export function run(ast: SvelteAst.Fragment): void { | ||
| const element = ast.nodes[0] as SvelteAst.RegularElement; | ||
| addAttribute(element, 'class', 'foo'); | ||
| } |
3 changes: 0 additions & 3 deletions
3
packages/sv/lib/core/tests/html/common/create-div/output.html
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { addFromRawHtml, type HtmlDocument } from '../../../../tooling/html/index.ts'; | ||
| import { addFromRawHtml, type SvelteAst } from '../../../../tooling/html/index.ts'; | ||
|
|
||
| export function run(ast: HtmlDocument): void { | ||
| addFromRawHtml(ast.childNodes, '<div style="display: flex" data-foo="bar">foo</div>'); | ||
| export function run(ast: SvelteAst.Fragment): void { | ||
| addFromRawHtml(ast, '<div style="display: flex" data-foo="bar">foo</div>'); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,68 @@ | ||
| import { | ||
| type HtmlChildNode, | ||
| type HtmlDocument, | ||
| HtmlElement, | ||
| HtmlElementType, | ||
| parseHtml | ||
| } from '../index.ts'; | ||
|
|
||
| export { HtmlElement, HtmlElementType }; | ||
| export type { HtmlDocument }; | ||
|
|
||
| export function createDiv(attributes: Record<string, string> = {}): HtmlElement { | ||
| return createElement('div', attributes); | ||
| } | ||
| import { parseHtml, type SvelteAst } from '../index.ts'; | ||
|
|
||
| export type { SvelteAst }; | ||
|
|
||
| export function createElement( | ||
| tagName: string, | ||
| attributes: Record<string, string> = {} | ||
| ): HtmlElement { | ||
| const element = new HtmlElement(tagName, {}, undefined, HtmlElementType.Tag); | ||
| element.attribs = attributes; | ||
| ): SvelteAst.RegularElement { | ||
| const element: SvelteAst.RegularElement = { | ||
| type: 'RegularElement', | ||
| name: tagName, | ||
| attributes: [], | ||
| fragment: { | ||
| type: 'Fragment', | ||
| nodes: [] | ||
| }, | ||
| name_loc: { start: { column: 0, line: 0 }, end: { column: 0, line: 0 } }, | ||
| start: 0, | ||
| end: 0 | ||
| }; | ||
|
|
||
| for (const [name, value] of Object.entries(attributes)) { | ||
| addAttribute(element, name, value); | ||
| } | ||
|
|
||
| return element; | ||
| } | ||
|
|
||
| export function insertElement(childNodes: HtmlChildNode[], elementToInsert: HtmlChildNode): void { | ||
| childNodes.splice(0, 0, elementToInsert); | ||
| export function addAttribute(element: SvelteAst.RegularElement, name: string, value: string): void { | ||
| let existing = element.attributes.find( | ||
| (attr): attr is SvelteAst.Attribute => attr.type === 'Attribute' && attr.name === name | ||
| ); | ||
|
|
||
| if (!existing) { | ||
| existing = { | ||
| type: 'Attribute', | ||
| name, | ||
| value: [], | ||
| start: 0, | ||
| end: 0, | ||
| name_loc: { start: { column: 0, line: 0 }, end: { column: 0, line: 0 } } | ||
| }; | ||
| element.attributes.push(existing); | ||
| } | ||
|
|
||
| existing.value = [{ type: 'Text', data: value, raw: value, start: 0, end: 0 }]; | ||
| } | ||
|
|
||
| export function insertElement( | ||
| fragment: SvelteAst.Fragment, | ||
| elementToInsert: SvelteAst.Fragment['nodes'][0] | ||
| ): void { | ||
| fragment.nodes.splice(0, 0, elementToInsert); | ||
| } | ||
|
|
||
| export function appendElement(childNodes: HtmlChildNode[], elementToAppend: HtmlChildNode): void { | ||
| childNodes.push(elementToAppend); | ||
| export function appendElement( | ||
| fragment: SvelteAst.Fragment, | ||
| elementToAppend: SvelteAst.Fragment['nodes'][0] | ||
| ): void { | ||
| fragment.nodes.push(elementToAppend); | ||
| } | ||
|
|
||
| export function addFromRawHtml(childNodes: HtmlChildNode[], html: string): void { | ||
| export function addFromRawHtml(fragment: SvelteAst.Fragment, html: string): void { | ||
| const document = parseHtml(html); | ||
| for (const childNode of document.childNodes) { | ||
| childNodes.push(childNode); | ||
| for (const childNode of document.nodes) { | ||
| fragment.nodes.push(childNode); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,15 @@ | ||
| { | ||
| "extends": "../../tsconfig.json", | ||
| "include": ["bin.ts"] | ||
| "include": ["bin.ts", "lib/**/*.ts"], | ||
| "exclude": [ | ||
| "dist/**", | ||
| "lib/core/tests/**/input.ts", | ||
| "lib/core/tests/**/output.ts", | ||
| "lib/create/templates/demo/**", | ||
| "lib/create/shared/vite.config.ts", | ||
| "lib/cli/tests/snapshots/**" | ||
| ], | ||
| "compilerOptions": { | ||
| "checkJs": false | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.