When using a custom icon set, the server rendering of Angular Universal outputs Error retrieving icon: NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XML and leaves the mat-icon tag empty.
Bug, feature request, or proposal:
Bug
What is the expected behavior?
Server-rendering of the mat-icon tag containing an SVG tag with the custom icon.
What is the current behavior?
Error message Error retrieving icon: NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XML and empty mat-icon tags. Client-side rendering works fine.
What are the steps to reproduce?
Defining a custom icon set in the app module in an Angular Universal project:
export class MaterialModule {
constructor(
matIconRegistry: MatIconRegistry,
domSanitizer: DomSanitizer,
@Inject(PLATFORM_ID) private platformId: Object
) {
const server = 'http://localhost:' + ('PORT' in process.env ? process.env.PORT : 4000);
const iconSetUrl = (isPlatformServer(this.platformId) ? server : '') + '/assets/mdi.svg';
matIconRegistry.addSvgIconSet(domSanitizer.bypassSecurityTrustResourceUrl(iconSetUrl));
}
}
Using an icon of the icon set like so:
<mat-icon svgIcon="gift"></mat-icon>
What is the use-case or motivation for changing an existing behavior?
Server-side rendering should work fine, even with custom icon sets.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
"@angular/animations": "^5.2.1",
"@angular/cdk": "^5.1.0",
"@angular/cli": "^1.5.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/compiler-cli": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/material": "^5.1.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/platform-server": "^5.0.0",
"@angular/router": "^5.0.0",
"@nguniversal/express-engine": "^5.0.0-beta.5",
"@nguniversal/module-map-ngfactory-loader": "^5.0.0-beta.5",
Is there anything else we should know?
Commenting out this line in the generated dist/server.js solves the issue.
When using a custom icon set, the server rendering of Angular Universal outputs
Error retrieving icon: NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XMLand leaves themat-icontag empty.Bug, feature request, or proposal:
Bug
What is the expected behavior?
Server-rendering of the
mat-icontag containing an SVG tag with the custom icon.What is the current behavior?
Error message
Error retrieving icon: NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XMLand emptymat-icontags. Client-side rendering works fine.What are the steps to reproduce?
Defining a custom icon set in the app module in an Angular Universal project:
Using an icon of the icon set like so:
What is the use-case or motivation for changing an existing behavior?
Server-side rendering should work fine, even with custom icon sets.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Is there anything else we should know?
Commenting out this line in the generated
dist/server.jssolves the issue.