Skip to content

Commit

Permalink
feat: use vue 3 global and composition api in ix-picture
Browse files Browse the repository at this point in the history
  • Loading branch information
luqven committed Jul 8, 2021
1 parent 0e05aa9 commit 3c3d626
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/plugins/vue-imgix/ix-picture.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import { ensureVueImgixClientSingleton, IVueImgixClient } from './vue-imgix';
import Vue, { CreateElement } from 'vue';
import Component from 'vue-class-component';
import { defineComponent, h } from 'vue';

const IxPictureProps = Vue.extend({
const IxPictureProps = defineComponent({
props: {},
});

@Component
export class IxPicture extends IxPictureProps {
// Using !: here because we ensure it is set in created()
private vueImgixSingleton!: IVueImgixClient;
export const IxPicture = defineComponent({
mixins: [IxPictureProps],
render() {
const vueImgixSingleton: IVueImgixClient = ensureVueImgixClientSingleton();

created() {
this.vueImgixSingleton = ensureVueImgixClientSingleton();
}

render(createElement: CreateElement) {
return createElement('picture', this.$slots.default);
}
}
return h('picture', this.$slots.default);
},
});

0 comments on commit 3c3d626

Please sign in to comment.