Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Commit

Permalink
Support registry factory for custom elements (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
agubler committed Mar 23, 2018
1 parent 4f907dc commit e42f1e3
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 65 deletions.
114 changes: 57 additions & 57 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions src/decorators/customElement.ts
@@ -1,5 +1,6 @@
import { Constructor, WidgetProperties } from '../interfaces';
import { CustomElementChildType } from '../registerCustomElement';
import Registry from '../Registry';

export type CustomElementPropertyNames<P extends object> = ((keyof P) | (keyof WidgetProperties))[];

Expand Down Expand Up @@ -28,6 +29,8 @@ export interface CustomElementConfig<P extends object = { [index: string]: any }
events?: CustomElementPropertyNames<P>;

childType?: CustomElementChildType;

registryFactory?: () => Registry;
}

/**
Expand All @@ -39,15 +42,17 @@ export function customElement<P extends object = { [index: string]: any }>({
properties = [],
attributes = [],
events = [],
childType = CustomElementChildType.DOJO
childType = CustomElementChildType.DOJO,
registryFactory = () => new Registry()
}: CustomElementConfig<P>) {
return function<T extends Constructor<any>>(target: T) {
target.prototype.__customElementDescriptor = {
tagName: tag,
attributes,
properties,
events,
childType
childType,
registryFactory
};
};
}
Expand Down

0 comments on commit e42f1e3

Please sign in to comment.