Components: svg icon registration doesn't work on server platform

Created on 1 Sep 2017  路  7Comments  路  Source: angular/components

Bug, feature request, or proposal:

Bug: svg icons doesn't work on server.

What is the expected behavior?

It should work on server too.

What is the current behavior?

Icon registration is tightly coupled with DOM and depends on document to be available which breaks its compatibility with server platform.

What are the steps to reproduce?

Use svg icons on server platform.

What is the use-case or motivation for changing an existing behavior?

It feels quite normal to have svg icons work on server.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

@angular/[email protected]

Is there anything else we should know?

Nope.

P3 has pr help wanted

Most helpful comment

Is server-side pre-rendering supposed to work? When I register icons, I provide an URL, which I'm pretty sure won't resolve while pre-rendering, given there's no server running. I tried nevertheless and I'm getting

Error retrieving icon:
ERROR [Error]

for each icon I'm trying to render. Build runs through though (without icons obviously). Looks like the error is triggered here.

Would it be possible to retrieve the files from the file system when isPlatformServer() is true so pre-rendering works? Or am I missing something on my side?

All 7 comments

Is it okay to use a library like jsdom to implement this ?

@FadySamirSadek unlikely, since platform-server uses domino see https://github.com/fgnass/domino

@Toxicable Thank you so much , i did not know that will do more research and hopefully do it

Is server-side pre-rendering supposed to work? When I register icons, I provide an URL, which I'm pretty sure won't resolve while pre-rendering, given there's no server running. I tried nevertheless and I'm getting

Error retrieving icon:
ERROR [Error]

for each icon I'm trying to render. Build runs through though (without icons obviously). Looks like the error is triggered here.

Would it be possible to retrieve the files from the file system when isPlatformServer() is true so pre-rendering works? Or am I missing something on my side?

Getting the same error as @freezy

I am getting the same error and I am using the latest version of the @angular/material package (5.2.4).

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xtianus79 picture xtianus79  路  3Comments

Miiekeee picture Miiekeee  路  3Comments

kara picture kara  路  3Comments

michaelb-01 picture michaelb-01  路  3Comments

julianobrasil picture julianobrasil  路  3Comments