mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
85194: Fix favicon switching in production mode
This commit is contained in:
@@ -36,7 +36,7 @@ import { Angulartics2DSpace } from './statistics/angulartics/dspace-provider';
|
|||||||
import { environment } from '../environments/environment';
|
import { environment } from '../environments/environment';
|
||||||
import { models } from './core/core.module';
|
import { models } from './core/core.module';
|
||||||
import { LocaleService } from './core/locale/locale.service';
|
import { LocaleService } from './core/locale/locale.service';
|
||||||
import { hasValue, isEmpty, isNotEmpty } from './shared/empty.util';
|
import { hasNoValue, hasValue, isNotEmpty } from './shared/empty.util';
|
||||||
import { KlaroService } from './shared/cookies/klaro.service';
|
import { KlaroService } from './shared/cookies/klaro.service';
|
||||||
import { GoogleAnalyticsService } from './statistics/google-analytics.service';
|
import { GoogleAnalyticsService } from './statistics/google-analytics.service';
|
||||||
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
||||||
@@ -246,7 +246,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
*/
|
*/
|
||||||
private setThemeCss(themeName: string): void {
|
private setThemeCss(themeName: string): void {
|
||||||
const head = this.document.getElementsByTagName('head')[0];
|
const head = this.document.getElementsByTagName('head')[0];
|
||||||
if (isEmpty(head)) {
|
if (hasNoValue(head)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,13 +276,13 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
|
|
||||||
private setHeadTags(themeName: string): void {
|
private setHeadTags(themeName: string): void {
|
||||||
const head = this.document.getElementsByTagName('head')[0];
|
const head = this.document.getElementsByTagName('head')[0];
|
||||||
if (isEmpty(head)) {
|
if (hasNoValue(head)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear head tags
|
// clear head tags
|
||||||
const currentHeadTags = Array.from(head.getElementsByClassName('theme-head-tag'));
|
const currentHeadTags = Array.from(head.getElementsByClassName('theme-head-tag'));
|
||||||
if (isNotEmpty(currentHeadTags)) {
|
if (hasValue(currentHeadTags)) {
|
||||||
currentHeadTags.forEach((currentHeadTag: any) => currentHeadTag.remove());
|
currentHeadTags.forEach((currentHeadTag: any) => currentHeadTag.remove());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,16 +299,16 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
const themeConfig = this.themeService.getThemeConfigFor(themeName);
|
const themeConfig = this.themeService.getThemeConfigFor(themeName);
|
||||||
const headTagConfigs = themeConfig?.headTags;
|
const headTagConfigs = themeConfig?.headTags;
|
||||||
|
|
||||||
if (isEmpty(headTagConfigs)) {
|
if (hasNoValue(headTagConfigs)) {
|
||||||
const parentThemeName = themeConfig?.extends;
|
const parentThemeName = themeConfig?.extends;
|
||||||
if (isNotEmpty(parentThemeName)) {
|
if (hasValue(parentThemeName)) {
|
||||||
// inherit the head tags of the parent theme
|
// inherit the head tags of the parent theme
|
||||||
return this.createHeadTags(parentThemeName);
|
return this.createHeadTags(parentThemeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultThemeName = DEFAULT_THEME_CONFIG.name;
|
const defaultThemeName = DEFAULT_THEME_CONFIG.name;
|
||||||
if (
|
if (
|
||||||
isEmpty(defaultThemeName) ||
|
hasNoValue(defaultThemeName) ||
|
||||||
themeName === defaultThemeName ||
|
themeName === defaultThemeName ||
|
||||||
themeName === BASE_THEME_NAME
|
themeName === BASE_THEME_NAME
|
||||||
) {
|
) {
|
||||||
@@ -335,7 +335,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
|||||||
private createHeadTag(headTagConfig: HeadTagConfig): HTMLElement {
|
private createHeadTag(headTagConfig: HeadTagConfig): HTMLElement {
|
||||||
const tag = this.document.createElement(headTagConfig.tagName);
|
const tag = this.document.createElement(headTagConfig.tagName);
|
||||||
|
|
||||||
if (isNotEmpty(headTagConfig.attributes)) {
|
if (hasValue(headTagConfig.attributes)) {
|
||||||
Object.entries(headTagConfig.attributes)
|
Object.entries(headTagConfig.attributes)
|
||||||
.forEach(([key, value]) => tag.setAttribute(key, value));
|
.forEach(([key, value]) => tag.setAttribute(key, value));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user