Skip to content

Commit 3e183ea

Browse files
committed
chore: remove unused str
1 parent 6d73b9a commit 3e183ea

File tree

1 file changed

+9
-36
lines changed

1 file changed

+9
-36
lines changed

src/runtime/initialChunkRetry.ts

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,9 @@ function validateTargetInfo(
8080
function createElement(
8181
origin: HTMLElement,
8282
attributes: ScriptElementAttributes,
83-
): { element: HTMLElement; str: string } | undefined {
83+
): HTMLElement | undefined {
8484
const crossOrigin =
8585
attributes.crossOrigin === true ? 'anonymous' : attributes.crossOrigin;
86-
const crossOriginAttr = crossOrigin ? `crossorigin="${crossOrigin}"` : '';
87-
const retryTimesAttr = attributes.times
88-
? `data-rb-retry-times="${attributes.times}"`
89-
: '';
90-
91-
const originalQueryAttr = attributes.originalQuery
92-
? `data-rb-original-query="${attributes.originalQuery}"`
93-
: '';
94-
95-
const ruleIndexAttr =
96-
attributes.ruleIndex >= 0 ? `data-rb-rule-i="${attributes.ruleIndex}"` : '';
97-
98-
const isAsyncAttr = attributes.isAsync ? 'data-rb-async' : '';
9986

10087
if (origin instanceof HTMLScriptElement) {
10188
const script = document.createElement('script');
@@ -116,14 +103,7 @@ function createElement(
116103
script.dataset.rbRuleI = String(attributes.ruleIndex);
117104
}
118105

119-
return {
120-
element: script,
121-
str:
122-
// biome-ignore lint/style/useTemplate: use "</" + "script>" instead of script tag to avoid syntax error when inlining in html
123-
`<script src="${attributes.url}" ${crossOriginAttr} ${retryTimesAttr} ${isAsyncAttr} ${ruleIndexAttr} ${originalQueryAttr}>` +
124-
'</' +
125-
'script>',
126-
};
106+
return script;
127107
}
128108
if (origin instanceof HTMLLinkElement) {
129109
const link = document.createElement('link');
@@ -143,25 +123,18 @@ function createElement(
143123
if (attributes.originalQuery !== undefined) {
144124
link.dataset.rbOriginalQuery = attributes.originalQuery;
145125
}
146-
return {
147-
element: link,
148-
str: `<link rel="${link.rel}" href="${
149-
attributes.url
150-
}" ${crossOriginAttr} ${retryTimesAttr} ${
151-
link.as ? `as="${link.as}"` : ''
152-
} ${ruleIndexAttr} ${originalQueryAttr}></link>`,
153-
};
126+
return link;
154127
}
155128
}
156129

157130
function reloadElementResource(
158131
origin: HTMLElement,
159-
fresh: { element: HTMLElement; str: string },
132+
freshElement: HTMLElement,
160133
attributes: ScriptElementAttributes,
161134
) {
162135
if (origin instanceof HTMLScriptElement) {
163136
if (attributes.isAsync) {
164-
document.body.appendChild(fresh.element);
137+
document.body.appendChild(freshElement);
165138
} else {
166139
console.warn(
167140
ERROR_PREFIX,
@@ -172,7 +145,7 @@ function reloadElementResource(
172145
}
173146

174147
if (origin instanceof HTMLLinkElement) {
175-
document.getElementsByTagName('head')[0].appendChild(fresh.element);
148+
document.getElementsByTagName('head')[0].appendChild(freshElement);
176149
}
177150

178151
if (origin instanceof HTMLImageElement) {
@@ -193,7 +166,7 @@ function retry(rules: NormalizedRuntimeRetryOptions[], e: Event) {
193166
// If the requested failed chunk is async chunk,skip it, because async chunk will be retried by asyncChunkRetry runtime
194167
if (
195168
typeof window !== 'undefined' &&
196-
Object.keys(window.__RB_ASYNC_CHUNKS__ || {}).some((chunkName) => {
169+
Object.keys(window.__RB_ASYNC_CHUNKS__ || {}).some(chunkName => {
197170
return url.indexOf(chunkName) !== -1;
198171
})
199172
) {
@@ -309,7 +282,7 @@ function registerInitialChunkRetry() {
309282
) {
310283
document.addEventListener(
311284
'error',
312-
(e) => {
285+
e => {
313286
if (e && e.target instanceof Element) {
314287
try {
315288
retry(config, e);
@@ -322,7 +295,7 @@ function registerInitialChunkRetry() {
322295
);
323296
document.addEventListener(
324297
'load',
325-
(e) => {
298+
e => {
326299
if (e && e.target instanceof Element) {
327300
try {
328301
load(config, e);

0 commit comments

Comments
 (0)