Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hpehl committed May 8, 2024
1 parent 3da1f18 commit 734eb33
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Add methods to modify the text node of an element:

- `Elements.textNode(elemental2.dom.Element, java.lang.String)`
- `Elements.textNode(org.jboss.elemento.IsElement<E>, java.lang.String)`
- `Elements.textNode(elemental2.dom.Element, String)`
- `Elements.textNode(IsElement<E>, String)`

- Add overloaded methods to bind events in `HasElement`:

Expand All @@ -21,6 +21,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

- Add `Logger.isEnabled(Level)` to check if a level is enabled for a logger.

### Changed

- Add debug log statements logger to attach/detach implementation

### Fixed

- Fix multiple attach/detach handlers for an element.

## [1.5.0] - 2024-05-06

### Added
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ class TodoItemElement implements IsElement<HTMLElement>, Attachable {

Elemento uses the [`MutationObserver`](https://developer.mozilla.org/docs/Web/API/MutationObserver) API to detect changes in the DOM tree and passes an [`MutationRecord`](https://developer.mozilla.org/en-US/docs/Web/API/MutationRecord) instance to the `attach(MutationRecord)` and `detach(MutationRecord)` methods. This instance contains additional information about the DOM manipulation.

> [!IMPORTANT]
> The `attach(MutationRecord)` and `detach(MutationRecord)` methods are only called **once** after the attachable implementation has been registered with `Attachable.register(HTMLElement, Attachable)`. If you hold a reference to the element, and the element is attached to the DOM again, the callbacks are not called again, unless the element has been registered again. This is done for reasons of optimisation and performance.

> [!TIP]
> If you want to be notified every time your custom element is attached to the DOM it is recommended to add the call to `Attachable.register(HTMLElement, Attachable)` in the constructor like in the example above and recreate the custom element.

## Iterators / Iterables / Streams

Elemento provides several methods to iterate over node lists, child elements or elements returned by a selector. There are methods which return `Iterator`, `Iterable` and `Stream`.
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jboss/elemento/Attachable.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* The {@link #attach(MutationRecord)} / {@link #detach(MutationRecord)} methods are only called <strong>once</strong> after the
* attachable implementation has been registered with {@link #register(HTMLElement, Attachable)}. If you hold a reference to the
* element, and the element is attached to the DOM again, the callbacks are not called again, unless the element has been
* registered again.
* registered again. This is done for reasons of optimisation and performance.
* <p>
* {@snippet class = Greeting region = attach}
*/
Expand Down

0 comments on commit 734eb33

Please sign in to comment.