question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`v-attr` with xlink namespace is not working

See original GitHub issue

I tried to write a v-attr with an xlink:href property. Unfortunately, I got a warning:

[Vue warn]: Invalid expression. Generated function body: scope.href:'/svg/ico.svg#'+scope.option.icon

I had the following code, which according to the stack overflow link must have worked at some point:

<svg class="icon icon--{{ option.icon }}">
    <use v-attr="xlink:href: '/svg/ico.svg#' + option.icon">
</svg>

http://stackoverflow.com/questions/26811126/using-v-attr-with-attribute-that-contains-colon-xmlnshref-does-not-compile

One problem I’ve seen in so far is that the xlink Regex in the directives/attr.js doesn’t match. But even fixing that, I’m still getting the same error:

Line 2: var xlinkRE = /^xlink:/ should be var xlinkRE = /^xlink/

Or am I completely misunderstanding the issue?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

18reactions
getsetbrocommented, May 29, 2017

I found in the docs that I can do this: <use v-bind="{'xlink:href':'#a'+item.name}"></use>

https://vuejs.org/v2/api/#v-bind

2reactions
yyx990803commented, Dec 19, 2014

You need to wrap your xlink:href in quotes so that Vue doesn’t treat the colon as an argument separator:

<use v-attr="'xlink:href' : '/svg/ico.svg#' + option.icon">
Read more comments on GitHub >

github_iconTop Results From Across the Web

SVG attribute namespaces · Issue #291 · d3/d3 - GitHub
I'm looking into using D3 to create <svg> s that I can convert to PDF, and I've been spending a lot of quality...
Read more >
C# SelectSingleNode with NameSpace issues - Stack Overflow
XPath doesn't work with default namespaces. You must create a prefix for the namespace. This code should work: XmlNamespaceManager nsm = new ...
Read more >
Namespaces crash course - SVG: Scalable Vector Graphics
The problem with mixing content from different XML dialects in a single XML document is that the elements defined by one dialect may...
Read more >
Namespaces and XSLT Stylesheets - XML.com
In XML a namespace is a collection of names used for elements and attributes. ... making the result document a working XLink document....
Read more >
Controlling Namespaces (XML Schema)
Schemas for XML, XML Base and XLink ... Importing Schemas with No Namespaces ... The problem of open schemas tightly controlling some namespaces...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found