-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Beeq Vue): remove applyPolyfills function
BEEQ integration with Vue.js is broken, 'cuz the latest Stencil version no longer copy polyfills to the dist OT unless building es5.
- Loading branch information
1 parent
1ef177c
commit 4502ae3
Showing
1 changed file
with
16 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
import { Plugin } from 'vue'; | ||
import { applyPolyfills, defineCustomElements } from '@beeq/core/dist/loader'; | ||
import { defineCustomElements } from '@beeq/core/dist/loader'; | ||
|
||
export const BeeqVue: Plugin = { | ||
async install() { | ||
applyPolyfills().then(() => { | ||
// @stencil/vue-output-target does not support camelCase event names | ||
// so we are attaching a custom event listener to map camelCase to kebab-case event names | ||
const camelCaseToKebab = (str: string) => { | ||
return str | ||
.split(/(?=[A-Z])/) | ||
.join('-') | ||
.toLowerCase(); | ||
}; | ||
defineCustomElements(window, { | ||
ael: (el: any, eventName: string, cb: any, opts: any) => | ||
el.addEventListener(camelCaseToKebab(eventName), cb, opts), | ||
rel: (el: any, eventName: string, cb: any, opts: any) => | ||
el.removeEventListener(camelCaseToKebab(eventName), cb, opts), | ||
ce: (eventName: string, opts: any) => new CustomEvent(camelCaseToKebab(eventName), opts), | ||
} as any); | ||
}); | ||
// @stencil/vue-output-target does not support camelCase event names | ||
// so we are attaching a custom event listener to map camelCase to kebab-case event names | ||
const camelCaseToKebab = (str: string) => { | ||
return str | ||
.split(/(?=[A-Z])/) | ||
.join('-') | ||
.toLowerCase(); | ||
}; | ||
defineCustomElements(window, { | ||
ael: (el: any, eventName: string, cb: any, opts: any) => | ||
el.addEventListener(camelCaseToKebab(eventName), cb, opts), | ||
rel: (el: any, eventName: string, cb: any, opts: any) => | ||
el.removeEventListener(camelCaseToKebab(eventName), cb, opts), | ||
ce: (eventName: string, opts: any) => new CustomEvent(camelCaseToKebab(eventName), opts), | ||
} as any); | ||
}, | ||
}; |