Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional options on the @CustomElement decorator #88

Closed
nborelli opened this issue Jul 9, 2017 · 1 comment
Closed

Optional options on the @CustomElement decorator #88

nborelli opened this issue Jul 9, 2017 · 1 comment
Assignees

Comments

@nborelli
Copy link

nborelli commented Jul 9, 2017

This is just my opinion, but I think this might be better with less decorators but with decorators that take an optional options object that conform to an interface. For example:

interface CustomElementOptions {
 name?: string;
 template?: string;
 styles?: Array<string> | string;
}

Usage:

@CustomElement({
 template: '<h2>Hello World</h2>',
 styles: [':host {display: block}', 'styles.css'] 
})
export class MyElement extends Polymer.Element {
   name: string;
}

This would be more in line with the way Angular uses decorators and provides a nice way to add additional options to the custom element in the future without introducing new decorators.

The options are themselves optional, so the minimum decorator syntax is:

@CustomElement()
export class MyElement extends Polymer.Element {
   name: string;
}

Where the name is inferred from the class name and kebab cased and the template file must match the TypeScript filename.

@nborelli nborelli changed the title Opional options on the @CustomElement decorator Optional options on the @CustomElement decorator Jul 9, 2017
@Buslowicz Buslowicz self-assigned this Jul 9, 2017
@Buslowicz
Copy link
Owner

Sounds good to me, it's an easy task so I'll do it asap :).

Buslowicz pushed a commit that referenced this issue Jul 11, 2017
Buslowicz pushed a commit that referenced this issue Jul 11, 2017
#88: Optional options on the @CustomElement decorator + fixing minor …
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants