bumbu/svg-pan-zoom

Uncaught errors thrown by events targeting children of a <foreignObject> element

Open

#51 opened on Jul 16, 2014

View on GitHub
 (7 comments) (0 reactions) (0 assignees)JavaScript (383 forks)batch import
bughelp wanted

Repository metrics

Stars
 (1,585 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

I'm working on a project which requires text wrapping and the approach I'm taking here is to embed an XHTML document inside a <foreignObject> element, as below.

<g>
  <polygon points="..."></polygon>
  <foreignObject>
    <body>
      <p>Blah blah, lorem ipsum something</p>
    </body>
  </foreignObject>
</g>

Now this renders just fine, panning is functional etc. but errors are thrown by events targeting anything inside the <foreignObject> element as neither evt.target.ownerSVGElement or evt.target.correspondingElement.ownerSVGElement are defined for these elements.

I've hacked in a "fix" which walks up the document tree until they are defined, but I doubt (in my limited experience with SVG/XML) that's a valid approach for much outside of a narrow use case so there's no pull request here.

Contributor guide