Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute Inheritance not working #96

Open
hungify2022 opened this issue Mar 25, 2023 · 0 comments
Open

Attribute Inheritance not working #96

hungify2022 opened this issue Mar 25, 2023 · 0 comments

Comments

@hungify2022
Copy link

hungify2022 commented Mar 25, 2023

Hi!
I try to implement Icon Base component based on the prop name but attributes(class, width, height) are not inherited.

I tried instead defineAsyncComponent(() => import(`../assets/${props.name}.svg?component`)) with any component it's perfectly fine.

Reproduction

main.ts

app.mixin({
  inheritAttrs: false,
});

IconBase.vue

<script lang="ts">
export default {
  inheritAttrs: true,
};
</script>

<script lang="ts" setup>
import { defineAsyncComponent, SVGAttributes, computed } from "vue";

interface IconProps extends SVGAttributes {
  name: "vue";
}

const props = defineProps<IconProps>();

const currentIcon = computed(() =>
  defineAsyncComponent(() => import(`../assets/${props.name}.svg?component`))
);
</script>

<template>
  <Component :is="currentIcon" class="icon" />
</template>

<style scoped>
.icon {
  display: inline-block;
  fill: currentColor;
  vertical-align: middle;
  flex-shrink: 0;
  user-select: none;
}
</style>

App.vue

<script setup lang="ts">
import IconBase from "./components/IconBase.vue";
</script>

<template>
  <IconBase name="vue" class="red" width="50" height="50" />
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant