Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
fix(themes): Add support change them in ssr mode
Browse files Browse the repository at this point in the history
  • Loading branch information
EndyKaufman committed Jun 16, 2018
1 parent a170396 commit 06d2d77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions libs/rucken/web/src/lib/modules/themes/themes.storage.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { isPlatformBrowser } from '@angular/common';
import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
import { AppStorage } from '@rucken/core';
import { DOCUMENT } from '@angular/platform-browser';
@Injectable()
export class ThemesStorage {

storageKeyName = 'theme';

constructor(
@Inject(AppStorage) private _cookies: Storage,
@Inject(DOCUMENT) private _document: any
) {
}
set(url: string) {
if (!url) {
this._cookies.removeItem(this.storageKeyName);
Expand All @@ -23,7 +29,7 @@ export class ThemesStorage {
}
setStyleLinkHref(url: string) {
if (url) {
const links = document.getElementsByTagName('link');
const links = this._document.getElementsByTagName('link');
if (links && links.length && url) {
for (let i = 0; i < links.length; i++) {
const link = links[i];
Expand All @@ -44,7 +50,7 @@ export class ThemesStorage {
}
}
getStyleLinkHref() {
const links = document.getElementsByTagName('link');
const links = this._document.getElementsByTagName('link');
if (links && links.length) {
for (let i = 0; i < links.length; i++) {
const link = links[i];
Expand All @@ -62,9 +68,4 @@ export class ThemesStorage {
}
return undefined;
}
constructor(
@Inject(AppStorage) private _cookies: Storage,
@Inject(PLATFORM_ID) private _platformId: Object
) {
}
}
2 changes: 1 addition & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Object.defineProperty(win.document.body.style, 'transform', {
};
},
});
global['document'] = win.document;
// global['document'] = win.document;
global['CSS'] = null;
// global['XMLHttpRequest'] = require('xmlhttprequest').XMLHttpRequest;
global['Prism'] = null;
Expand Down

0 comments on commit 06d2d77

Please # to comment.