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
Copy file name to clipboardExpand all lines: README.md
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -14,16 +14,17 @@ Version 0.8.1
14
14
15
15
To bind events on, pass states to, and execute effects on elements, UIElement offers a chainable API on `this.self`, `this.first(selector)` or `this.all(selector)` with a `map()` method - just like arrays.
16
16
17
-
For example, `this.self.map(on('click', 'clicked', () => true))` binds an event handler for `'click'` on the custom element itself, setting its `'clicked'` state to `true`. With `this.all('sub-component').map(pass(this, { color: 'color' }))` you pass the `'color'` state on `this` to every instance of `<sub-component>` in the DOM subtree.
17
+
For example, `this.self.map(on('click', () => this.set('clicked', true))` binds an event handler for `'click'` on the custom element itself, setting its `'clicked'` state to `true`. With `this.all('sub-component').map(pass({ color: 'color' }))` you pass the `'color'` state on `this` to every instance of `<sub-component>` in the DOM subtree.
18
18
19
-
There are 6 pre-defined auto-effects that can be applied on elements with `this.[self|first(selector)|all(selector)].map()`:
19
+
There are 7 pre-defined auto-effects that can be applied on elements with `this.[self|first(selector)|all(selector)].map()`:
20
20
21
21
-`setText(state)`: set text content of the target element to the value of state; expects a state of type string; will preserve comment nodes inside the element
22
22
-`setProperty(key, state=key)`: set a property of the target element to the value of state; accepts a state of any type
23
23
-`setAttribute(name, state=name)`: set or remove an attribute on the element to the value of state; expects a state of type string (set) or undefined (remove)
24
24
-`toggleAttribute(name, state=name)`: toggles a boolean attribute on the element according to the value of state; expects a state of type boolean
25
25
-`toggleClass(token, state=token)`: toggles a class on the element according to the value of state; expects a state of type boolean
26
26
-`setStyle(prop, state=prop)`: set an inline style on the element to the value of state; expects a state of type string for the CSS property value
27
+
-`dispatch(event, state=event)`: dispatch a custom event with the value of state as detail; accepts a state of any type
27
28
28
29
You can define custom effects with `effect()`, either in the `connectedCallback()` or in a mapped function on `this.[self|first(selector)|all(selector)]`. `UIElement` will automatically trigger these effects and bundle the fine-grained DOM updates.
29
30
@@ -65,8 +66,8 @@ class MyCounter extends UIElement {
0 commit comments