Skip to content

Commit

Permalink
Update Proposal.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bahrus committed Jul 21, 2024
1 parent 821a8e5 commit de365bd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
24 changes: 22 additions & 2 deletions xtal-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export class XtalElement extends O {
type: 'String',
attrName: 'shadow-root-mode',
parse: true,
},
inherits: {
type: 'String',
attrName: 'inherits',
parse: true,
}
},
actions: {
Expand Down Expand Up @@ -115,7 +120,7 @@ export class XtalElement extends O {
};
}
async define(self) {
const { aka, mainTemplate, assumeCSR, inferProps, xform, propInfo, propDefaults, shadowRootMode } = self;
const { aka, mainTemplate, assumeCSR, inferProps, xform, propInfo, propDefaults, shadowRootMode, inherits } = self;
const inferredProps = {};
const inferredXForm = {};
if (inferProps) {
Expand Down Expand Up @@ -154,7 +159,22 @@ export class XtalElement extends O {
mode: shadowRootMode
};
}
const ctr = class extends Mount {
let inheritingClass = Mount;
switch (typeof inherits) {
case 'string':
inheritingClass = (await customElements.whenDefined(inherits));
break;
case 'function':
if (inherits.bootUp) {
inheritingClass = inherits;
}
else {
if (inherits.constructor.name === 'AsyncFunction') {
inheritingClass = (await inherits());
}
}
}
const ctr = class extends inheritingClass {
localize = localize;
static config = {
assumeCSR,
Expand Down
12 changes: 11 additions & 1 deletion xtal-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,18 @@ export class XtalElement extends O implements Actions{
case 'string':
inheritingClass = (await customElements.whenDefined(inherits)) as typeof Mount;
break;
case 'function':
if((<any>inherits).bootUp) {
inheritingClass = inherits as typeof Mount;
}else{
if(inherits.constructor.name === 'AsyncFunction'){
inheritingClass = (await (<any>inherits)()) as typeof Mount;
}

}

}
const ctr = class extends Mount {
const ctr = class extends inheritingClass {
localize = localize;
static override config: MntCfg = {
assumeCSR,
Expand Down

0 comments on commit de365bd

Please sign in to comment.