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.

Attribute collision when one is bound and the other is not (using : shortand and not v-bind)

See original GitHub issue

I upgraded my dependencies and I have some issues with the latest version (1.4.6). By testing the older releases, it appears that the bug got introduced on version 1.3.0 (1.2.18 works fine).

My code:

      <img
        svg-inline
        src="../../assets/icon.svg"
        class="fill-current menu-icon"
        :class="{ 'text-red-900': !active }"
      />

Expected output: <svg> tag with at least the static classes (fill-current menu-icon)

Instead I get: the static part is removed, only the :class part is respected ( )

Interestingly, if I make a trivial modification to the class (add a whitespace for instance), the hot-reload injects the updated static classes and everything looks fine again.


Furthermore, if I replace :class with v-bind:class

  • on v1.3.0, everything seems to be fine
  • on v1.4.6 the compilation fails with duplicate attribute: v-bind:class

Probably relevant commit: https://github.com/oliverfindl/vue-svg-inline-loader/commit/f5f0a0ff1b44f5de9381f70c991089892901ef99 (#28)

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
oliverfindlcommented, Mar 15, 2020

Hello,

I updated loader and published it to npm. Current version is 1.5.0.

You can turn off transformation to v-bind: syntax with transformImageAttributesToVueDirectives option.

Please give me feedback if it works as expected.

Thanks

1reaction
oliverpoolcommented, Mar 15, 2020

I will try to think about the best solution for this issue, but I’m not sure about outcome. As workaround you can use your :class on parent element and style it as a child of this parent. I know, it’s not convenient, but it should do the trick.

An easier workaround (without change to my CSS) is to manually merge my static class inside my bounded :class:

:class="{ 'text-red-900': !active, 'fill-current menu-icon': true }"
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I solve "Interpolation inside attributes has been ...
Vue template syntax error: id="purchase-{{ item.id }}": Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead.
Read more >
Binding syntax - Angular
Data binding works with properties of DOM elements, components, and directives, not HTML attributes. HTML attributes and DOM propertieslink. Angular binding ...
Read more >
Shorthands for Events and Bindings in Vue - Coding Explained -
The shorthand for this directive is simply a colon followed by the name of the attribute to bind to. In this case, we...
Read more >
GDScript basics - Godot Docs
Saves a variable along with the resource it's attached to and makes it visible ... null is an empty data type that contains...
Read more >
Hibernate ORM 5.4.33.Final User Guide - Red Hat on GitHub
While having a strong background in SQL is not required to use Hibernate, ... is another form of a value type, and its...
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