Repository: sveltejs/kit
Pull request #8425 (2023-01-09 22:44:05)

remove unused flags
these are no longer used anywhere

changeset-bot[bot]: ###  ⚠️  No Changeset found

Latest commit: 32a5780cd640622b1a62e0ddd15547cf10d16a56

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. **If these changes should result in a version bump, you need to add a changeset.**

<details><summary>This PR includes no changesets</summary>

  When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

</details>

[Click here to learn what changesets are, and how to add one](https://github.com/changesets/changesets/blob/master/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add a changeset to this PR](https://github.com/sveltejs/kit/new/remove-unused-flags?filename=.changeset/wise-phones-yawn.md&value=---%0A%22%40sveltejs%2Fkit%22%3A%20patch%0A---%0A%0Aremove%20unused%20flags%0A)


benmccann: The test failure looks possibly related:
```
@sveltejs/kit:test:   1) [chromium-dev-no-js] › test\test.js:1049:2 › $app/environment › includes version ==============
@sveltejs/kit:test: 
@sveltejs/kit:test:     Error: expect(received).toBe(expected) // Object.is equality
@sveltejs/kit:test: 
@sveltejs/kit:test:     Expected: "TEST_VERSION"
@sveltejs/kit:test:     Received: ""
```

I'll kick off the tests again...

Patch:
diff --git a/.changeset/friendly-cycles-roll.md b/.changeset/friendly-cycles-roll.md
deleted file mode 100644
index 1583855eb..000000000
--- a/.changeset/friendly-cycles-roll.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-'@sveltejs/kit': patch
----
-
-[fix] invalidate implicit dependencies in server load functions
diff --git a/packages/kit/CHANGELOG.md b/packages/kit/CHANGELOG.md
index 96204e97a..69ae22803 100644
--- a/packages/kit/CHANGELOG.md
+++ b/packages/kit/CHANGELOG.md
@@ -1,5 +1,15 @@
 # @sveltejs/kit
 
+## 1.0.11
+
+### Patch Changes
+
+- Warn if comments are removed from HTML ([#8423](https://github.com/sveltejs/kit/pull/8423))
+
+- [fix] ignore `<a>` elements with no `href` attribute ([#8418](https://github.com/sveltejs/kit/pull/8418))
+
+- [fix] invalidate implicit dependencies in server load functions ([#8420](https://github.com/sveltejs/kit/pull/8420))
+
 ## 1.0.10
 
 ### Patch Changes
diff --git a/packages/kit/package.json b/packages/kit/package.json
index cb3005c62..92127716b 100644
--- a/packages/kit/package.json
+++ b/packages/kit/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "@sveltejs/kit",
-	"version": "1.0.10",
+	"version": "1.0.11",
 	"repository": {
 		"type": "git",
 		"url": "https://github.com/sveltejs/kit",
diff --git a/packages/kit/src/runtime/client/utils.js b/packages/kit/src/runtime/client/utils.js
index aa14bcce7..25d3980a9 100644
--- a/packages/kit/src/runtime/client/utils.js
+++ b/packages/kit/src/runtime/client/utils.js
@@ -105,7 +105,7 @@ function parent_element(element) {
  */
 export function find_anchor(element, target) {
 	while (element && element !== target) {
-		if (element.nodeName.toUpperCase() === 'A') {
+		if (element.nodeName.toUpperCase() === 'A' && element.hasAttribute('href')) {
 			return /** @type {HTMLAnchorElement | SVGAElement} */ (element);
 		}
 
diff --git a/packages/kit/src/runtime/server/page/render.js b/packages/kit/src/runtime/server/page/render.js
index 030b43561..851c1b04c 100644
--- a/packages/kit/src/runtime/server/page/render.js
+++ b/packages/kit/src/runtime/server/page/render.js
@@ -6,6 +6,7 @@ import { s } from '../../../utils/misc.js';
 import { Csp } from './csp.js';
 import { uneval_action_response } from './actions.js';
 import { clarify_devalue_error } from '../utils.js';
+import { DEV } from 'esm-env';
 
 // TODO rename this function/module
 
@@ -353,17 +354,34 @@ export async function render_response({
 	// add the content after the script/css links so the link elements are parsed first
 	head += rendered.head;
 
+	const html = options.app_template({
+		head,
+		body,
+		assets,
+		nonce: /** @type {string} */ (csp.nonce)
+	});
+
 	// TODO flush chunks as early as we can
-	const html =
+	const transformed =
 		(await resolve_opts.transformPageChunk({
-			html: options.app_template({ head, body, assets, nonce: /** @type {string} */ (csp.nonce) }),
+			html,
 			done: true
 		})) || '';
 
+	if (DEV && page_config.csr) {
+		if (transformed.split('<!--').length < html.split('<!--').length) {
+			// the \u001B stuff is ANSI codes, so that we don't need to add a library to the runtime
+			// https://svelte.dev/repl/1b3f49696f0c44c881c34587f2537aa2
+			console.warn(
+				"\u001B[1m\u001B[31mRemoving comments in transformPageChunk can break Svelte's hydration\u001B[39m\u001B[22m"
+			);
+		}
+	}
+
 	const headers = new Headers({
 		'x-sveltekit-page': 'true',
 		'content-type': 'text/html',
-		etag: `"${hash(html)}"`
+		etag: `"${hash(transformed)}"`
 	});
 
 	if (!state.prerendering) {
@@ -381,7 +399,7 @@ export async function render_response({
 		}
 	}
 
-	return new Response(html, {
+	return new Response(transformed, {
 		status,
 		headers
 	});
diff --git a/packages/kit/types/internal.d.ts b/packages/kit/types/internal.d.ts
index 4d558c88e..2b32e3397 100644
--- a/packages/kit/types/internal.d.ts
+++ b/packages/kit/types/internal.d.ts
@@ -383,11 +383,8 @@ export * from './private';
 
 declare global {
 	const __SVELTEKIT_ADAPTER_NAME__: string;
-	const __SVELTEKIT_APP_VERSION__: string;
 	const __SVELTEKIT_APP_VERSION_FILE__: string;
 	const __SVELTEKIT_APP_VERSION_POLL_INTERVAL__: number;
-	const __SVELTEKIT_BROWSER__: boolean;
-	const __SVELTEKIT_DEV__: boolean;
 	const __SVELTEKIT_EMBEDDED__: boolean;
 	var Bun: object;
 	var Deno: object;


Test patch:
diff --git a/packages/kit/test/apps/basics/src/routes/routing/missing-href/+page.svelte b/packages/kit/test/apps/basics/src/routes/routing/missing-href/+page.svelte
new file mode 100644
index 000000000..c9b90c330
--- /dev/null
+++ b/packages/kit/test/apps/basics/src/routes/routing/missing-href/+page.svelte
@@ -0,0 +1,12 @@
+<script>
+	import { afterNavigate } from '$app/navigation';
+
+	let count = 0;
+
+	afterNavigate(() => {
+		count += 1;
+	});
+</script>
+
+<!-- svelte-ignore a11y-missing-attribute -->
+<a data-testid="count">count: {count}</a>
diff --git a/packages/kit/test/apps/basics/test/client.test.js b/packages/kit/test/apps/basics/test/client.test.js
index afe4f0f4d..6ea8f881f 100644
--- a/packages/kit/test/apps/basics/test/client.test.js
+++ b/packages/kit/test/apps/basics/test/client.test.js
@@ -789,19 +789,15 @@ test.describe('Routing', () => {
 	});
 
 	test('does not normalize external path', async ({ page }) => {
-		/** @type {Array<string|undefined>} */
-		const urls = [];
-
-		const { port, close } = await start_server((req, res) => {
-			if (req.url !== '/favicon.ico') urls.push(req.url);
-			res.end('ok');
+		const { port, close } = await start_server((_req, res) => {
+			res.end('<html><head></head><body>ok</body></html>');
 		});
 
 		try {
 			await page.goto(`/routing/slashes?port=${port}`);
 			await page.locator(`a[href="http://localhost:${port}/with-slash/"]`).click();
-
-			expect(urls).toEqual(['/with-slash/']);
+			expect(await page.content()).toBe('<html><head></head><body>ok</body></html>');
+			expect(page.url()).toBe(`http://localhost:${port}/with-slash/`);
 		} finally {
 			await close();
 		}
@@ -846,6 +842,16 @@ test.describe('Routing', () => {
 		expect(await page.textContent('h2')).toBe('form');
 		expect(await page.textContent('h3')).toBe('bar');
 	});
+
+	test('ignores links with no href', async ({ page }) => {
+		await page.goto('/routing/missing-href');
+		const selector = '[data-testid="count"]';
+
+		expect(await page.textContent(selector)).toBe('count: 1');
+
+		await page.locator(selector).click();
+		expect(await page.textContent(selector)).toBe('count: 1');
+	});
 });
 
 test.describe('Shadow DOM', () => {