I'm running into an issue where Prince 13.1 fails to recognize the "xlink:href" attribute I set on a number of SVG <use /> elements from JavaScript. For example the following code properly adds a reference to another node so that it is rendered by browsers:
But in Prince I instead get a warning and the element is not rendered:
A complete reproduction is available at https://gist.github.com/natevw/59962c3499a72e9c3ced42150e36b21e — it should render a green square next to a red one, but Prince's output includes only the red square and logs "use: @xlink:href required" for the other.
Note that this can be reproduced with direct JavaScript DOM manipulation but is actually being encountered within a large React codebase where the SVG attribute in question can not simply be moved to any inline HTML.
Is there any JavaScript-based workaround we can use? I already tried both of these [otherwise incorrect solutions] on a lark, but both leave me with the same error:
(The latter attempt throws a DOMException in Chrome but not under Prince.)
useEl.setAttributeNS("http://www.w3.org/1999/xlink", 'href', "#testing123");
But in Prince I instead get a warning and the element is not rendered:
prince: prince_svg_js_namespace.html: warning: svg: use: @xlink:href required.
A complete reproduction is available at https://gist.github.com/natevw/59962c3499a72e9c3ced42150e36b21e — it should render a green square next to a red one, but Prince's output includes only the red square and logs "use: @xlink:href required" for the other.
Note that this can be reproduced with direct JavaScript DOM manipulation but is actually being encountered within a large React codebase where the SVG attribute in question can not simply be moved to any inline HTML.
Is there any JavaScript-based workaround we can use? I already tried both of these [otherwise incorrect solutions] on a lark, but both leave me with the same error:
// attempt #1
useEl.setAttribute('xlink:href', "#testing123");
// attempt #2
useEl.setAttribute('@xlink:href', "#testing123");
(The latter attempt throws a DOMException in Chrome but not under Prince.)
Edited by natevw