Skip to content

Commit

Permalink
Skip processing svg anchor elements
Browse files Browse the repository at this point in the history
Fixes #5589 by skipping
processing of a elements that are not `HTMLAnchorElement`s, including
those within SVG elements. Currently, if you have a `a` element
inside an SVG element it will break HTML rendering since that element
does not have a `href` like other `a` elements do.
  • Loading branch information
saulshanabrook committed Nov 11, 2018
1 parent c0a8595 commit 984768f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/rendermime/src/renderers.ts
Expand Up @@ -628,15 +628,21 @@ namespace Private {
// Handle anchor elements.
let anchors = node.getElementsByTagName('a');
for (let i = 0; i < anchors.length; i++) {
let path = anchors[i].href || '';
const el = anchors[i];
// skip when processing a elements inside svg
// which are of type SVGAnimatedString
if (!(el instanceof HTMLAnchorElement)) {
continue;
}
let path = el.href;
const isLocal =
resolver && resolver.isLocal
? resolver.isLocal(path)
: URLExt.isLocal(path);
if (isLocal) {
anchors[i].target = '_self';
el.target = '_self';
} else {
anchors[i].target = '_blank';
el.target = '_blank';
}
}

Expand Down

0 comments on commit 984768f

Please sign in to comment.