ngneat / svg-icon

👻 A lightweight library that makes it easier to use SVG icons in your Angular Application
https://netbasal.com
MIT License
260 stars 35 forks source link

document is not defined when using Angular Universal #11

Closed MostafaYehia closed 3 years ago

MostafaYehia commented 3 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[x] Support request
[ ] Other... Please describe:

Current behavior

ERROR ReferenceError: document is not defined

 
    toElement(content) {
        const div = document.createElement('DIV');
        div.innerHTML = content;
        const svgElement = div.querySelector('svg');
        if (!svgElement) {
            throw Error(' tag not found');
        }
        return svgElement;
    }

Expected behavior

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Support Angular Universal

Environment


Angular version: 10.1.6


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX

For Tooling issues:
- Node version: XX  
- Platform:  

Others: