Skip to content

Commit

Permalink
fix: deal with boolean attribute with empty value (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzyang1995 authored Feb 18, 2024
1 parent e6832e0 commit 9a61e57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 3 additions & 4 deletions packages/core/src/module/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,9 @@ export class App {
async: false,
defer: false,
isInline: jsManager.isInlineScript(),
noEntry: toBoolean(
entryManager.findAttributeValue(node, 'no-entry') ||
this.isNoEntryScript(targetUrl),
),
noEntry:
toBoolean(entryManager.findAttributeValue(node, 'no-entry')) ||
toBoolean(this.isNoEntryScript(targetUrl)),
originScript: mockOriginScript,
});
}
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/module/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ function fetchStaticResources(
.map((node) => {
const src = entryManager.findAttributeValue(node, 'src');
const type = entryManager.findAttributeValue(node, 'type');
const crossOrigin = entryManager.findAttributeValue(
let crossOrigin = entryManager.findAttributeValue(
node,
'crossorigin',
);
if (crossOrigin === '') {
crossOrigin = 'anonymous';
}

// There should be no embedded script in the script element tag with the src attribute specified
if (src) {
Expand Down
2 changes: 1 addition & 1 deletion packages/loader/src/managers/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class TemplateManager {
}

findAttributeValue(node: Node, type: string) {
return node.attributes?.find(({ key }) => key === type)?.value || undefined;
return node.attributes?.find(({ key }) => key === type)?.value ?? undefined;
}

cloneNode(node: Node) {
Expand Down

0 comments on commit 9a61e57

Please sign in to comment.