Skip to content

Commit 4e510bb

Browse files
authored
fix: white screen when src is empty string (#10)
1 parent e397fe9 commit 4e510bb

22 files changed

+52
-6
lines changed

src/runtime/initialChunkRetry.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,18 @@ function getRequestUrl(element: HTMLElement) {
4343
element instanceof HTMLScriptElement ||
4444
element instanceof HTMLImageElement
4545
) {
46+
// For <script src="" /> or <img src="" />
47+
// element.getAttribute('src') === '' but element.src === baseURI
48+
if (!element.getAttribute('src')) {
49+
return null;
50+
}
4651
return element.src;
4752
}
4853
if (element instanceof HTMLLinkElement) {
54+
// For <link href="" />
55+
if (!element.getAttribute('href')) {
56+
return null;
57+
}
4958
return element.href;
5059
}
5160
return null;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/helper.ts renamed to test/basic/helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { stripVTControlCharacters as stripAnsi } from 'node:util';
22
import type { Page } from '@playwright/test';
33
import { type RequestHandler, createRsbuild } from '@rsbuild/core';
44
import { pluginReact } from '@rsbuild/plugin-react';
5-
import { type PluginAssetsRetryOptions, pluginAssetsRetry } from '../dist';
5+
import { type PluginAssetsRetryOptions, pluginAssetsRetry } from '../../dist';
66

77
const portMap = new Map();
88

test/index.test.ts renamed to test/basic/index.test.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ test('should work when the first, second cdn are all failed and the third is suc
8686
[],
8787
{
8888
minify: true,
89-
domain: [
90-
'a.com/foo-path',
91-
'b.com',
92-
`localhost:${port}`,
93-
],
89+
domain: ['a.com/foo-path', 'b.com', `localhost:${port}`],
9490
addQuery: true,
9591
onRetry(context) {
9692
console.info('onRetry', context);
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)