Skip to content

Commit

Permalink
fix: do not throw errors on SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
navix committed Jun 25, 2022
1 parent 3edc0b1 commit 3ff487d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"lib:publish": "npm publish ./dist/icong --access=public",
"lib:publish:beta": "npm publish ./dist/icong --access=public --tag=beta",
"lib:release": "npm run lib:build && npm run lib:publish",
"lib:release:beta": "npm run lib:build && npm run lib:publish:beta",
"website:serve": "ng run website:serve",
"website:build": "ng run website:build:production",
"website:deploy": "ng run website:deploy --cname=icong.oleksanovyk.com"
Expand Down
2 changes: 1 addition & 1 deletion projects/icong/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "icong",
"version": "14.0.1",
"version": "14.0.2",
"description": "Efficient Angular SVG Icons.",
"keywords": ["angular", "icons", "svg"],
"author": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<svg
height="200"
style="display: none;"
version="1.1"
viewBox="0 0 500 200"
width="500"
xmlns="http://www.w3.org/2000/svg"
Expand Down
15 changes: 13 additions & 2 deletions projects/icong/src/lib/icons-host/icons-host.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
import { IconsRegistry } from '../icons-registry';

Expand All @@ -15,14 +16,21 @@ export class IconsHostComponent implements OnInit {
fill?: string;
}[] = [];

isBrowser = false;

constructor(
private registry: IconsRegistry,
private cdr: ChangeDetectorRef,
private sanitizer: DomSanitizer,
@Inject(PLATFORM_ID) platformId: any,
) {
this.isBrowser = isPlatformBrowser(platformId);
}

ngOnInit() {
if (!this.isBrowser) {
return;
}
this.registry
.reqIcons$
.subscribe(icons => {
Expand All @@ -49,7 +57,10 @@ export class IconsHostComponent implements OnInit {
});
}

trackByFn(index, item: {name: string}) {
trackByFn(
index,
item: {name: string},
) {
return item.name;
}
}

0 comments on commit 3ff487d

Please sign in to comment.