fix v-sl-model crash

feat/vaults
Tomáš Mládek 2021-03-24 20:38:04 +01:00
parent 54c1ea711d
commit a4d70273ba
1 changed files with 6 additions and 6 deletions

View File

@ -1,8 +1,8 @@
import * as Vue from "vue";
import {DirectiveBinding} from "vue";
import { DirectiveBinding } from "vue";
import App from "./App.vue";
import router from "./router";
import {defineCustomElements, setAssetPath, SlInput,} from "@shoelace-style/shoelace";
import { defineCustomElements, setAssetPath, SlInput, } from "@shoelace-style/shoelace";
// TODO: Remove when UI settles!
defineCustomElements();
@ -10,17 +10,15 @@ setAssetPath(`${window.location.origin}/${process.env.VUE_APP_ASSET_PATH}/`);
const app = Vue.createApp(App);
app.use(router);
app.mount("#app");
app.config.isCustomElement = (tag: string) => Boolean(tag.match(/^sl-/));
app.directive("sl-model", {
beforeMount: (element: Element, binding: DirectiveBinding<string>) => {
element.addEventListener("slInput", (event) => {
const slElement = event?.target as
| typeof SlInput.prototype
| undefined;
| typeof SlInput.prototype
| undefined;
const value = slElement?.value;
if (value && binding.instance) {
(binding.instance.$data as { [key: string]: unknown })[binding.arg as string] = value;
@ -34,3 +32,5 @@ app.directive("sl-model", {
}
},
});
app.mount("#app");