mirror of
https://github.com/archtechx/alpine-typescript.git
synced 2025-12-12 06:44:03 +00:00
v0.1.16
This commit is contained in:
parent
b44e59682a
commit
459caba878
3 changed files with 17 additions and 4 deletions
12
src/index.ts
12
src/index.ts
|
|
@ -1,5 +1,3 @@
|
|||
declare const window: any;
|
||||
|
||||
type ComponentConstructor = (...args: any[]) => object;
|
||||
|
||||
export abstract class AlpineComponent {
|
||||
|
|
@ -113,7 +111,7 @@ export function convertClassToAlpineConstructor(component: any): ComponentConstr
|
|||
}
|
||||
|
||||
export function addTitles(): void {
|
||||
window.Alpine.onBeforeComponentInitialized((component: AlpineComponent) => {
|
||||
window.Alpine.onBeforeComponentInitialized((component: ComponentController) => {
|
||||
if (! component.$el.hasAttribute('x-title')) {
|
||||
if (component.$data.constructor.prototype instanceof AlpineComponent) {
|
||||
component.$el.setAttribute('x-title', component.$data.constructor.name);
|
||||
|
|
@ -137,3 +135,11 @@ export function bootstrap(): void {
|
|||
if (window.AlpineComponents === undefined) {
|
||||
bootstrap();
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
Alpine: Alpine;
|
||||
deferLoadingAlpine: any;
|
||||
AlpineComponents: any;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue