crisbeto / angular-svg-round-progressbar

Angular module that uses SVG to create a circular progressbar
https://crisbeto.github.io/angular-svg-round-progressbar/
MIT License
741 stars 173 forks source link

[Universal] NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XML #164

Open feimosi opened 6 years ago

feimosi commented 6 years ago

When using it with Angular Universal I get the following error on the server:

ERROR { NAMESPACE_ERR: NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XML
  code: 14,
  message: 'NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XML',
  name: 'NAMESPACE_ERR' }

Enclosing the <round-progress> inside *ngIf="isPlatformBrowser" doesn't help at all. This may be related: angular/material2#7866

oleersoy commented 6 years ago

If you remove this block from [RoundProgressiveService]() does it still throw?:

    this.supportsSvg = !!(
      document &&
      document.createElementNS &&
      document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect
    );
feimosi commented 6 years ago

Yes, still the same error.

oleersoy commented 6 years ago

Seems more like a problem with Angular Universal than with this component. I wonder if Angular Universal is attempting to schema check the template before it is compiled, so it's seeing things like getPathTransform() and saying "HEY YAO - We don't know anything about this!".

I could also be that it just blows up for svg in general. If that's the case then any valid SVG like the goey spinner should blow it up. Could try replacing the template in the component with this:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  <defs>
    <filter id="goo">
      <feGaussianBlur in="SourceGraphic" stdDeviation="10" result="blur" />
      <feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 21 -7"/>
    </filter>
  </defs>
</svg>

If the build works with that as the template then at least we are a little closer to knowing what's causing it. Could also try with bare svg like this:

<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
</svg>
crisbeto commented 6 years ago

AFAIK that only happens when setting the xmlns through a template. It's most likely throwing because of this instance in particular.

oleersoy commented 6 years ago

This demo runs in chrome with both the xmlns and version attributes removed from the svg element. I can check on SO if they are required when declaring inline svg elements if need be.

So if you remove the xmlns and version attributes, does the build work?

feimosi commented 6 years ago

Could try replacing the template in the component with this:

So if you remove the xmlns and version attributes, does the build work?

I've just tried the snippet from above and I can confirm:

oleersoy commented 6 years ago

The attributes are optional for inlined svg so it should be fine to remove them.

CaerusKaru commented 6 years ago

This is a duplicate of https://github.com/angular/angular/issues/21196. It will be resolved with https://github.com/angular/angular/issues/22263