alex-oleshkevich / vue-tabler-icons

Fully customizable free SVG icons made as Vue components.
MIT License
150 stars 13 forks source link

bug: inject all $data into html may cause errors #20

Closed nerijunior closed 2 years ago

nerijunior commented 2 years ago

In https://github.com/alex-oleshkevich/vue-tabler-icons/blob/master/build.js#L24

const allAttrs = {
    ...this.$data,
    width: attrs.width || size,
    height: attrs.height || size,
}

...this.$data will inject all the available data inside the element and it will cause errors when using libraries/plugins that adds data to Vue components like @vue/apollo-option.

Vue Apollo will allow all components in the application to have an $apolloData object inside this.$data and the Icon will try to put $apolloData inside the <svg {...allAttrs} ... tag.

It will cause:

 Failed to execute 'setAttribute' on 'Element': '$apolloData' is not a valid attribute name.
alex-oleshkevich commented 2 years ago

This made intentionally to let you pass any arguments to the icon component like:

<bold-icon stroke-width="2" data-attr="value">

Please make sure that this still works.

nerijunior commented 2 years ago

@alex-oleshkevich If that's the idea we should use this.$attrs instead of this.$data, makes sense?

alex-oleshkevich commented 2 years ago

merged, thanks!