Skip to content

Commit

Permalink
fix(framework): redundant fonts loading (#7868)
Browse files Browse the repository at this point in the history
fix(framework): font loading

Co-authored-by: Nayden Naydenov <[email protected]>
  • Loading branch information
2 people authored and ilhan007 committed Dec 13, 2023
1 parent 4fd4b79 commit abbd5e5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/base/src/ManagedStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ const updateStyle = (data: StyleData, name: string, value = "") => {
}
};

const hasStyle = (name: string, value = "") => {
const hasStyle = (name: string, value = ""): boolean => {
if (shouldUseLinks()) {
return !!document.querySelector(`head>link[${name}="${value}"]`);
}

const styleElement = document.querySelector(`head>style[${name}="${value}"]`);

if (document.adoptedStyleSheets && !isSafari()) {
return !!document.adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === getStyleId(name, value));
return !!styleElement || !!document.adoptedStyleSheets.find(sh => (sh as Record<string, any>)._ui5StyleId === getStyleId(name, value));
}

return !!document.querySelector(`head>style[${name}="${value}"]`);
return !!styleElement;
};

const removeStyle = (name: string, value = "") => {
Expand Down

0 comments on commit abbd5e5

Please sign in to comment.