You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can specific any [attachShadow options](https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow#options) in the config object and they are all optional. The default matches their native default values.
138
+
You can specify any [attachShadow options](https://developer.mozilla.org/en-US/docs/Web/API/Element/attachShadow#options) in the config object, and they are all optional. The default matches their native default values.
139
139
140
140
```javascript
141
141
classMyButtonextendsWebComponent {
@@ -174,7 +174,7 @@ class MyButton extends WebComponent {
174
174
customElements.define('my-button', MyButton)
175
175
```
176
176
177
-
In the render method you can return anything: a string, a [DOM Node](https://developer.mozilla.org/en-US/docs/Web/API/Node), a [Markup template](../templating/index.md), a `null` value, or nothing at all. Some components can just handle some internal logic and dont need to render anything but their tags.
177
+
In the render method, you can return anything: a string, a [DOM Node](https://developer.mozilla.org/en-US/docs/Web/API/Node), a [Markup template](../templating/index.md), a `null` value, or nothing at all. Some components can just handle some internal logic and don't need to render anything but their tags.
178
178
179
179
### Stylesheet
180
180
@@ -191,7 +191,7 @@ class MyButton extends WebComponent {
191
191
customElements.define('my-button', MyButton)
192
192
```
193
193
194
-
Where the style is added will depend on whether the shadow option is true or false. If the component has shadow stylewill be added to its own [content root](./web-component.md#content-root). Otherwise, style will be added to the closest root node the component was rendered in. It can be the document itself or [root](./web-component.md#root) of an ancestor web component.
194
+
Where the style is added will depend on whether the shadow option is true or false. If the component has a shadow style, it will be added to its own [content root](./web-component.md#content-root). Otherwise, style will be added to the closest root node in which the component was rendered. It can be the document itself or [root](./web-component.md#root) of an ancestor web component.
195
195
196
196
#### css
197
197
@@ -212,7 +212,7 @@ class MyButton extends WebComponent {
212
212
customElements.define('my-button', MyButton)
213
213
```
214
214
215
-
It helps your IDE give you better CSS syntax highlight and autocompletion but it does not perform any computation to your CSS at this point.
215
+
It helps your IDE give you better CSS syntax highlighting and autocompletion, but it does not perform any computation on your CSS at this point.
216
216
217
217
#### updateStylesheet
218
218
@@ -230,7 +230,7 @@ class MyButton extends WebComponent {
230
230
customElements.define('my-button', MyButton)
231
231
```
232
232
233
-
To define the default values for your props, simply define a property in the class with same name and provide the value.
233
+
To define the default values for your props, simply define a property in the class with the same name and provide the value.
If you have state, you will need to update it. To do that you can call the `setState` method with a whole or partially new state object or simply a callback function that returns the state.
296
+
If you have a state, you will need to update it. To do that, you can call the `setState` method with a whole or partially new state object or simply a callback function that returns the state.
297
297
298
298
```typescript
299
299
interfaceState {
@@ -317,7 +317,7 @@ class MyButton extends WebComponent<{}, State> {
317
317
customElements.define('my-button', MyButton)
318
318
```
319
319
320
-
if you provide a partial state object it will be merged with the current state object. No need to spread state when updating it.
320
+
If you provide a partial state object, it will be merged with the current state object. No need to spread state when updating it.
321
321
322
322
You can also provide a callback so you can access the current state data.
323
323
@@ -352,7 +352,7 @@ class MyButton extends WebComponent {
352
352
customElements.define('my-button', MyButton)
353
353
```
354
354
355
-
This `dispatch` method also takes a second argument which can be the data you want to expose with the event.
355
+
This `dispatch` method also takes a second argument, which can be the data you want to expose with the event.
The `onUpdate` method is called whenever the component props are updated via the `setAttribute` or changing the props property on the element instance directly.
411
+
The `onUpdate` method is called whenever the component props are updated via the `setAttribute` or by changing the props property on the element instance directly.
412
412
413
413
```javascript
414
414
classMyButtonextendsWebComponent {
@@ -420,7 +420,7 @@ class MyButton extends WebComponent {
420
420
customElements.define('my-button', MyButton)
421
421
```
422
422
423
-
The method will always tell you, which prop and its new and old value.
423
+
The method will always tell you which prop and its new and old values.
The `onError` method is called whenever the component fails to perform internal actions. These action can also be related to code executed inside any lifecycle methods, render, state or style update.
441
+
The `onError` method is called whenever the component fails to perform internal actions. These actions can also be related to code executed inside any lifecycle methods, render, state or style update.
442
442
443
443
```javascript
444
444
classMyButtonextendsWebComponent {
@@ -466,7 +466,7 @@ class MyButton extends WebComponent {
466
466
customElements.define('my-button', MyButton)
467
467
```
468
468
469
-
You can also enhance components so all errors are handled in the same place.
469
+
You can also enhance components so that all errors are handled in the same place.
470
470
471
471
```javascript
472
472
// have your global componenent that extends WebComponent
@@ -526,8 +526,8 @@ const field = new TextField()
526
526
field.contentRoot// ShadowRoot object
527
527
```
528
528
529
-
This is not to be confused with the Node returned by calling the [getRootNode()](https://developer.mozilla.org/en-US/docs/Web/API/Node/getRootNode) on an element. The getRootNode will return the element context root node and contentRoot will contain the node where the template was rendered to.
529
+
This is not to be confused with the Node returned by calling the [getRootNode()](https://developer.mozilla.org/en-US/docs/Web/API/Node/getRootNode) on an element. The getRootNode will return the element context root node, and contentRoot will contain the node where the template was rendered to.
530
530
531
531
### Root
532
532
533
-
The `root` tells you about where the component was rendered at. It can either be the document itself, or the ancestor element shadow root.
533
+
The `root` tells you about where the component was rendered. It can either be the document itself or the ancestor element shadow root.
0 commit comments