Skip to content

Commit 4701bd4

Browse files
authored
Update documentation for working without decorators (#7129)
# Pull Request ## 📖 Description After looking into #7128 it was discovered that actually the updated syntax for adding attributes was never updated in the documentation. This is therefore not a bug fix, but a documentation update. ### 🎫 Issues Resolves #7128 ## ✅ Checklist ### General <!--- Review the list and put an x in the boxes that apply. --> - [ ] I have included a change request file using `$ npm run change` - [ ] I have added tests for my changes. - [x] I have tested my changes. - [x] I have updated the project documentation to reflect my changes. - [x] I have read the [CONTRIBUTING](https://github.com/microsoft/fast/blob/main/CONTRIBUTING.md) documentation and followed the [standards](https://github.com/microsoft/fast/blob/main/CODE_OF_CONDUCT.md#our-standards) for this project. ## ⏭ Next Steps - Run an update to push the change to the documentation site
1 parent 3ae4941 commit 4701bd4

File tree

1 file changed

+34
-36
lines changed

1 file changed

+34
-36
lines changed

sites/website/src/docs/advanced/working-without-decorators.md

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,21 @@ keywords:
88

99
Most of our documented examples include the use of TypeScript decorators. However, as decorators are an unimplemented feature in JavaScript, using them may not be right for your project. See [TypeScript documentation](https://www.typescriptlang.org/docs/handbook/decorators.html) for details on our implementation.
1010

11-
The static `definition` accepts the same configuration options as the `@attr` decorator. For example, to bind a property name that is different from an attribute name:
11+
When defining your component, you may pass in attributes in the same configuration object as the name, template, and styles:
1212

1313
```javascript
1414
import { FASTElement, html, css } from '@microsoft/fast-element';
1515

1616
export class MyElement extends FASTElement {
17-
static definition = {
17+
// component logic
18+
}
19+
20+
MyElement.define({
1821
name: 'my-element',
1922
template: html`<div>${(x) => x.count}</div>`,
2023
styles: css`div { background: red }`,
21-
attributes: [
22-
'count',
23-
],
24-
};
25-
}
26-
27-
FASTElement.define(MyElement);
24+
attributes: ['count'],
25+
});
2826
```
2927

3028
```html
@@ -37,22 +35,24 @@ This accepts the same configuration options as the `@attr` so for example to bin
3735
import { FASTElement, html, css } from '@microsoft/fast-element';
3836

3937
export class MyElement extends FASTElement {
40-
static definition = {
41-
name: 'my-element',
42-
template: html`<div>${(x) => x.currentCount}</div>`,
43-
styles: css`div { background: red }`,
44-
attributes: [
45-
{
46-
attribute: 'current-count',
47-
property: 'currentCount'
48-
},
49-
],
50-
};
51-
5238
currentCount = 42;
5339
}
5440

55-
FASTElement.define(MyElement);
41+
MyElement.define({
42+
name: 'my-element',
43+
template: html`<div>${(x) => x.currentCount}</div>`,
44+
styles: css`div { background: red }`,
45+
attributes: [
46+
{
47+
attribute: 'current-count',
48+
property: 'currentCount'
49+
},
50+
],
51+
});
52+
```
53+
54+
```html
55+
<my-element current-count="42">
5656
```
5757

5858
If you need to add a converter to your attribute:
@@ -70,21 +70,19 @@ const converter = {
7070
};
7171

7272
export class MyElement extends FASTElement {
73-
static definition = {
74-
name: 'my-element',
75-
template: html`<div>${(x) => x.currentCount}</div>`,
76-
styles: css`div { background: red }`,
77-
attributes: [
78-
{
79-
attribute: 'current-count',
80-
property: 'currentCount',
81-
converter
82-
},
83-
],
84-
};
85-
8673
currentCount = 42;
8774
}
8875

89-
FASTElement.define(MyElement);
76+
MyElement.define({
77+
name: 'my-element',
78+
template: html`<div>${(x) => x.currentCount}</div>`,
79+
styles: css`div { background: red }`,
80+
attributes: [
81+
{
82+
attribute: 'current-count',
83+
property: 'currentCount',
84+
converter
85+
},
86+
],
87+
});
9088
```

0 commit comments

Comments
 (0)