Skip to content

Commit

Permalink
Fix bug in BodyObserver removing wrong elements on detach due to a …
Browse files Browse the repository at this point in the history
…wrong CSS attribute selector
  • Loading branch information
hpehl committed Sep 13, 2024
1 parent 90b6b84 commit f7c19c7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Fix bug in `BodyObserver` removing wrong elements on detach due to a wrong CSS attribute selector
- Wrong selector: `<attribute>*=<id>`
- Correct selector: `<attribute>=<id>`

## [1.6.8] - 2024-08-21

### Added
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/org/jboss/elemento/BodyObserver.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ private static void onElementsRemoved(MutationRecord record) {
}
}

private static boolean isChildOfObservedElement(List<HTMLElement> elements, String attribute, String attachId) {
private static boolean isChildOfObservedElement(List<HTMLElement> elements, String attribute, String id) {
for (HTMLElement element : elements) {
if (element.querySelector("[" + attribute + "*='" + attachId + "']") != null) {
if (element.querySelector("[" + attribute + "='" + id + "']") != null) {
return true;
}
}
Expand Down

0 comments on commit f7c19c7

Please sign in to comment.