Skip to content

Commit

Permalink
fix: use attrs destrucuring to access context
Browse files Browse the repository at this point in the history
The new setup function allows you to desctrucutre context to bring in element attributes. I hadn't read this section properly and was therefore struggling to get data-testid to work. This commit undos the hot-fix and correctly reads the context attributes.
  • Loading branch information
luqven committed Jul 8, 2021
1 parent b0a6293 commit 83536d6
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/plugins/vue-imgix/ix-img.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ const IxImgProps = {
attributeConfig: Object,
disableVariableQuality: Boolean,
sizes: [String],
// TODO(luis): remove dataTestId props in favor of a better solution
dataTestId: {
type: String,
required: false,
}
};

const defaultAttributeMap = {
Expand All @@ -28,7 +23,7 @@ const defaultAttributeMap = {
export const IxImg = defineComponent({
props: IxImgProps,

setup(props) {
setup(props, { attrs }) {
const vueImgixSingleton = ensureVueImgixClientSingleton();
const imgixParamsFromImgAttributes = {
...(props.fixed && {
Expand Down Expand Up @@ -60,8 +55,7 @@ export const IxImg = defineComponent({
width: props.width,
height: props.height,
sizes: props.sizes,
// TODO(luis): remove dataTestId props in favor of a better solution
['data-testid']: props.dataTestId || undefined,
['data-testid']: attrs['data-testid'] || undefined,
});
},
});

0 comments on commit 83536d6

Please sign in to comment.