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
@@ -78,40 +78,40 @@ The actions syntax follows a pattern of `event:controller#method`.
78
78
Multiple actions can be bound to multiple events, methods, and controllers. For example:
79
79
80
80
```html
81
-
<analytics-controller>
82
-
<hello-controller>
81
+
<analytics-tracking>
82
+
<hello-world>
83
83
<input
84
-
data-target="hello-controller.name"
84
+
data-target="hello-world.name"
85
85
data-action="
86
-
input:hello-controller#validate
87
-
blur:hello-controller#validate
88
-
focus:analytics-controller#hover
86
+
input:hello-world#validate
87
+
blur:hello-world#validate
88
+
focus:analytics-tracking#hover
89
89
"
90
90
type="text"
91
91
>
92
92
93
93
<button
94
94
data-action="
95
-
click:hello-controller#greet
96
-
click:analytics-controller#click
97
-
hover:analytics-controller#hover
95
+
click:hello-world#greet
96
+
click:analytics-tracking#click
97
+
hover:analytics-tracking#hover
98
98
"
99
99
>
100
100
Greet
101
101
</button>
102
-
</hello-controller>
103
-
</analytics-controller>
102
+
</hello-world>
103
+
</analytics-tracking>
104
104
```
105
105
106
106
### Custom Events
107
107
108
-
A Controller may emit custom events, which may be listened to by other Controllers using the same Actions Syntax. There is no extra syntax needed for this. For example a `lazy-controller` may dispatch a `loaded` event, once its contents are loaded, and other controllers can listen to this event:
108
+
A Controller may emit custom events, which may be listened to by other Controllers using the same Actions Syntax. There is no extra syntax needed for this. For example a `lazy-load` Controller may dispatch a `loaded` event, once its contents are loaded, and other controllers can listen to this event:
Copy file name to clipboardExpand all lines: docs/_guide/decorators.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,15 +15,15 @@ Catalyst comes with the `@controller` decorator. This gets put on top of the cla
15
15
16
16
```js
17
17
@controller
18
-
classMyControllerextendsHTMLElement {}
18
+
classHelloWorldElementextendsHTMLElement {}
19
19
```
20
20
21
21
### Class Field Decorators
22
22
23
23
Catalyst comes with the `@target` and `@targets` decorators for more [read about Targets](/guide/targets). These get added on top or to the left of the field name, like so:
24
24
25
25
```js
26
-
classMyControllerextendsHTMLElement {
26
+
classHelloWorldElementextendsHTMLElement {
27
27
28
28
@target something
29
29
@@ -43,7 +43,7 @@ Catalyst doesn't currently ship with any method decorators, but you might see th
43
43
44
44
45
45
```js
46
-
classMyControllerextendsHTMLElement {
46
+
classHelloWorldElementextendsHTMLElement {
47
47
48
48
@log
49
49
submit() {
@@ -64,7 +64,7 @@ class MyController extends HTMLElement {
64
64
Some decorators are customisable - they get called with additional arguments, just like a function call. An example of this is the `@debounce` decorator in the [`@github/mini-throttle`](https://github.com/github/mini-throttle) package:
Copy file name to clipboardExpand all lines: docs/_guide/your-first-component.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,14 @@ chapter: 2
6
6
Custom Elements allow you to create reusable components that you can declare in HTML, and [progressively enhance](https://en.wikipedia.org/wiki/Progressive_enhancement) within JavaScript. Custom Elements must named with a `-` in the HTML name, and the JS class must `extend HTMLElement`. When the browser connects each element class instance to the DOM node, `connectedCallback` is fired - this is where you can change parts of the element. Here's a basic example:
Catalyst will automatically "dasherize" the class name. All capital letters get lowercased and dash separated.
44
+
Catalyst will automatically convert the classes name; removing the trailing `Element` suffix and lowercasing all capital letters, separating them with a dash.
45
45
46
-
By convention, Catalyst controllers end in `Controller`, but it's not required.
46
+
By convention, Catalyst controllers end in `Element`, and Catalyst will strip this for the tag name, but suffixing `Element` is not required. All examples in this guide use `Element` suffixed names.
47
47
48
48
#### What about without Decorators?
49
49
50
50
If you don't want to use decorators, you can simply wrap the class in a call to `controller`:
0 commit comments