Skip to content

Commit

Permalink
Support non-namespaced href attribute
Browse files Browse the repository at this point in the history
The SVG 2 specification deprecated usage of the xlink namespace when specifying resource references (href attribute) in supported SVG elements.
https://svgwg.org/svg2-draft/linking.html#XLinkRefAttrs
  • Loading branch information
bsweeney committed Sep 6, 2022
1 parent 058524e commit 76876c6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Svg/Tag/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public function start($attributes)
$this->href = $attributes['xlink:href'];
}

if (isset($attributes['href'])) {
$this->href = $attributes['href'];
}

$this->document->getSurface()->transform(1, 0, 0, -1, 0, $height);

$this->document->getSurface()->drawImage($this->href, $this->x, $this->y, $this->width, $this->height);
Expand Down
2 changes: 1 addition & 1 deletion src/Svg/Tag/UseTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function before($attributes)

$document = $this->getDocument();

$link = $attributes["xlink:href"];
$link = $attributes["href"] ?? $attributes["xlink:href"];
$this->reference = $document->getDef($link);

if ($this->reference) {
Expand Down

0 comments on commit 76876c6

Please sign in to comment.