achilles 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +2 -3
- data/Rakefile +1 -0
- data/app/javascript/achilles/application/dom-mutation-observer/observer.js +13 -3
- data/app/javascript/achilles/components/components_registry.js +20 -7
- data/docs/releases/v1.1.4.md +16 -0
- data/docs/upgrading.md +1 -0
- data/lib/achilles/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e59beb8e8ab33df4ada94377c9fc2b6dd6ae961c92c763cc8c512aa0c5fa5d8
|
|
4
|
+
data.tar.gz: 4b11194cec10e35dc71b6a421f12bf3ad4fcfb686d379c4fb4945f20bb64ba3e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5987a86094329766c89ef1288865da37e5ea856a11dd84fc3e73b3f4087388fcd35675968643674b019ab8ae04039902397ac427e082c177f9f4204adc7340ee
|
|
7
|
+
data.tar.gz: 0b0d801e5a7f4ce5263804a13164ae33ee5ca999eac205471bed8e8a3eb649378c6323e5c920d8b77ee4bc0200e9881e5749b4fa454489aa4b1fdf2d9559bdf1
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to Achilles will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 1.1.4
|
|
6
|
+
|
|
7
|
+
### Performance
|
|
8
|
+
|
|
9
|
+
- Speed up component registration by querying each component's ID directly in
|
|
10
|
+
the browser while preserving duplicate-ID detection.
|
|
11
|
+
- Skip component discovery for text-only DOM updates and reconcile changes
|
|
12
|
+
to component markers and IDs.
|
|
13
|
+
- Limit Turbo Frame teardown lookups to registered components in the
|
|
14
|
+
outgoing frame.
|
|
15
|
+
|
|
5
16
|
## 1.1.3
|
|
6
17
|
|
|
7
18
|
### Fixed
|
data/CONTRIBUTING.md
CHANGED
data/README.md
CHANGED
|
@@ -8,9 +8,8 @@ Achilles scans the page for elements with `data-component-class`, instantiates
|
|
|
8
8
|
the matching JavaScript class, and calls `setup` and `teardown` as Turbo renders
|
|
9
9
|
new pages or new component markup is inserted.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
[1.1.3 release notes](docs/releases/v1.1.3.md).
|
|
11
|
+
If you are upgrading an existing app, see the [upgrade index](docs/upgrading.md)
|
|
12
|
+
for version-specific notes.
|
|
14
13
|
|
|
15
14
|
## Why Achilles?
|
|
16
15
|
|
data/Rakefile
CHANGED
|
@@ -9,7 +9,12 @@ class Observer {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
config() {
|
|
12
|
-
return {
|
|
12
|
+
return {
|
|
13
|
+
attributes: true,
|
|
14
|
+
attributeFilter: ["id", "data-component-class"],
|
|
15
|
+
childList: true,
|
|
16
|
+
subtree: true,
|
|
17
|
+
};
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
start() {
|
|
@@ -22,8 +27,13 @@ class Observer {
|
|
|
22
27
|
this._callbackScheduled = false;
|
|
23
28
|
}
|
|
24
29
|
|
|
25
|
-
domChangedCallback(mutationsList
|
|
26
|
-
if (this._callbackScheduled) {
|
|
30
|
+
domChangedCallback(mutationsList) {
|
|
31
|
+
if (this._callbackScheduled || !mutationsList.some((mutation) => {
|
|
32
|
+
// Replacing text cannot add or remove component roots.
|
|
33
|
+
return mutation.type !== "childList" ||
|
|
34
|
+
Array.from(mutation.addedNodes).some((node) => node.nodeType !== Node.TEXT_NODE) ||
|
|
35
|
+
Array.from(mutation.removedNodes).some((node) => node.nodeType !== Node.TEXT_NODE);
|
|
36
|
+
})) {
|
|
27
37
|
return;
|
|
28
38
|
}
|
|
29
39
|
|
|
@@ -6,7 +6,15 @@ class ComponentsRegistry {
|
|
|
6
6
|
strictLifecycleErrors = false;
|
|
7
7
|
|
|
8
8
|
matchingElementsForId(id) {
|
|
9
|
-
|
|
9
|
+
if(typeof id !== 'string')
|
|
10
|
+
return [];
|
|
11
|
+
|
|
12
|
+
const css = globalThis.window?.CSS;
|
|
13
|
+
// CSS selectors cannot preserve null characters or unpaired surrogates.
|
|
14
|
+
const selector = id !== '' && !/[\0\uD800-\uDFFF]/u.test(id) && typeof css?.escape === 'function'
|
|
15
|
+
? `#${css.escape(id)}`
|
|
16
|
+
: '[id]';
|
|
17
|
+
return [...document.querySelectorAll(selector)].filter((elem) => elem.id === id);
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
elementForId(id) {
|
|
@@ -134,20 +142,25 @@ class ComponentsRegistry {
|
|
|
134
142
|
if(!rootElement || typeof rootElement.contains !== 'function')
|
|
135
143
|
return;
|
|
136
144
|
|
|
145
|
+
const candidateIds = typeof rootElement.querySelectorAll === 'function'
|
|
146
|
+
? new Set([rootElement.id, ...Array.from(rootElement.querySelectorAll('[id]'), (element) => element.id)])
|
|
147
|
+
: null;
|
|
148
|
+
|
|
137
149
|
Object.values(this._registeredComponents)
|
|
138
150
|
.filter((component) => {
|
|
139
151
|
if(component.id === AppConstants.PageComponentId)
|
|
140
152
|
return false;
|
|
153
|
+
if(candidateIds && !candidateIds.has(component.id))
|
|
154
|
+
return false;
|
|
141
155
|
|
|
142
156
|
let element = this.elementForId(component.id);
|
|
143
157
|
return element && rootElement.contains(element);
|
|
144
158
|
})
|
|
145
|
-
.
|
|
146
|
-
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.teardownAndDeregister(component.id);
|
|
159
|
+
.map(({ id }) => ({ id, depth: this.elementDepth(id) }))
|
|
160
|
+
.sort((first, second) => second.depth - first.depth)
|
|
161
|
+
.forEach(({ id }) => {
|
|
162
|
+
if(this.getRegisteredComponent(id))
|
|
163
|
+
this.teardownAndDeregister(id);
|
|
151
164
|
});
|
|
152
165
|
}
|
|
153
166
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Achilles 1.1.4
|
|
2
|
+
|
|
3
|
+
Achilles now looks up each component ID directly when registering it. Duplicate
|
|
4
|
+
IDs still prevent registration. Text-only DOM changes no longer trigger a
|
|
5
|
+
component scan. On Turbo Frame replacement, Achilles finds the outgoing
|
|
6
|
+
components inside the frame and tears down children before their parents.
|
|
7
|
+
|
|
8
|
+
## Upgrading
|
|
9
|
+
|
|
10
|
+
Update to `1.1.4` using the existing component markup and registration code.
|
|
11
|
+
Verify Turbo Frame replacement, browser history restoration, and dynamic
|
|
12
|
+
component insertion in your application. If you are upgrading from a version
|
|
13
|
+
earlier than `1.1.0`, start with the [1.1.0 upgrade guide](../upgrading-to-1.1.0.md).
|
|
14
|
+
|
|
15
|
+
- [Changelog](../../CHANGELOG.md)
|
|
16
|
+
- [Upgrade index](../upgrading.md)
|
data/docs/upgrading.md
CHANGED
data/lib/achilles/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: achilles
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jey Geethan
|
|
@@ -93,6 +93,7 @@ files:
|
|
|
93
93
|
- docs/releases/v1.1.1.md
|
|
94
94
|
- docs/releases/v1.1.2.md
|
|
95
95
|
- docs/releases/v1.1.3.md
|
|
96
|
+
- docs/releases/v1.1.4.md
|
|
96
97
|
- docs/upgrading-to-1.1.0.md
|
|
97
98
|
- docs/upgrading.md
|
|
98
99
|
- lib/achilles.rb
|