Skip to content

Commit 9924fdf

Browse files
committed
core: Fixed web-view props cascading
1 parent 6c42e41 commit 9924fdf

File tree

5 files changed

+87
-33
lines changed

5 files changed

+87
-33
lines changed

demo/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525
"@fortawesome/fontawesome-svg-core": "^6.5.2",
2626
"@fortawesome/free-solid-svg-icons": "^6.5.2",
2727
"@fortawesome/react-fontawesome": "^0.2.2",
28-
"@prozilla-os/ball-maze": "latest",
28+
"@prozilla-os/ball-maze": "^1.0.6",
2929
"@prozilla-os/bliss-radio": "latest",
3030
"@prozilla-os/logic-sim": "workspace:*",
31-
"@prozilla-os/minesweeper": "latest",
31+
"@prozilla-os/minesweeper": "^1.0.6",
3232
"@prozilla-os/skins": "workspace:*",
33-
"@prozilla-os/wordle": "latest",
33+
"@prozilla-os/wordle": "^1.1.7",
3434
"@taygotfound/melodix": "latest",
3535
"prozilla-os": "workspace:*",
3636
"react": "^18.3.1",

packages/core/src/components/_utils/web-view/WebView.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,21 @@ export const WebView: FC<WebViewProps> = forwardRef<HTMLIFrameElement>(({ source
3535
setHovered(false);
3636
};
3737

38+
const iframeProps = { ...props };
39+
40+
delete iframeProps.active;
41+
delete iframeProps.close;
42+
delete iframeProps.setTitle;
43+
delete iframeProps.setIconUrl;
44+
delete iframeProps.standalone;
45+
3846
return <div className={styles.WebView} onMouseOver={onMouseOver} onMouseOut={onMouseOut}>
3947
<iframe
4048
ref={ref}
4149
src={source}
4250
referrerPolicy="no-referrer"
4351
sandbox="allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts"
44-
{...props}
52+
{...iframeProps}
4553
/>
4654
</div>;
4755
}) as FC;

packages/core/src/features/_utils/browser.utils.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ export function setViewportTitle(title: string) {
3737
}
3838

3939
export function setViewportIcon(url: string) {
40-
let link: HTMLLinkElement | null = document.querySelector("link[rel~='icon']");
41-
if (link == null) {
42-
link = document.createElement("link");
40+
const links = document.querySelectorAll("link[rel~='icon'], link[rel~='apple-touch-icon']");
41+
42+
if (links.length == 0) {
43+
const link = document.createElement("link");
4344
link.rel = "icon";
45+
link.href = url;
4446
document.head.appendChild(link);
4547
}
46-
link.href = url;
48+
49+
links.forEach((link) => {
50+
(link as HTMLLinkElement).href = url;
51+
});
4752
}
4853

4954
export function getViewportParams(): Record<string, string> {

packages/dev-tools/src/plugins/stageSite.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ function generateAppPages(context: PluginContext, template: string, options: Sta
164164
const canonicalRegex = /(?<=(<link rel="canonical" href="|<meta name="twitter:url" content="|<meta property="og:url" content="))(http(s)?:\/\/[a-zA-Z-.]+\/)(?=("\/?>))/g;
165165
html = html.replaceAll(canonicalRegex, baseUrl + appId);
166166

167-
const iconRegex = /(?<=<link [^>]*rel="icon" [^>]*href=")[^"]+(?="[^>]*>)/g;
167+
const iconRegex = /(?<=<link [^>]*rel="(apple-touch-)?icon" [^>]*href=")[^"]+(?="[^>]*>)/g;
168168
html = html.replaceAll(iconRegex, `${appIcon}?x=${Math.round(Date.now() / 3_600_000)}`);
169169

170170
const faqRegex = /(<!-- FAQ -->.*?)?<script type="application\/ld\+json">.*?<\/script>/gs;

pnpm-lock.yaml

Lines changed: 65 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)