Skip to content

<defs> not allowed inside <svg>聽#23

Description

@cblaettl

Hi 馃憢,

First of all thank you very much for this awesome library, I like it a lot!

But I got a question: I'd like to fill the backrgound of my sparkline with a gradient, like so:

<svg
  width="300"
  height="60"
  stroke-width="3"
  style="fill: url(#fade)"
>
  <defs>
    <linearGradient id="fade" gradientTransform="rotate(90)">
      <stop offset="0%" stop-color="currentColor" />
      <stop offset="100%" stop-color="transparent" />
    </linearGradient>
  </defs>
</svg>

But this throws the following error, because sparkline tries to remove all children of the element first.

Uncaught (in promise) DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.

Do you have any idea how to prevent this error?

Thanks,
Christian

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions