stimulus-rails 1.2.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/stimulus-loading.js +7 -5
- data/app/assets/javascripts/stimulus.js +272 -111
- data/app/assets/javascripts/stimulus.min.js +1 -1
- data/app/assets/javascripts/stimulus.min.js.map +1 -1
- data/lib/generators/stimulus/stimulus_generator.rb +3 -1
- data/lib/stimulus/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9343efc3e70276ca902f488bd6e421abfc33bc7f5f4ae54510ed7fe5861793f
|
4
|
+
data.tar.gz: e8ee4935ceab92da342873ccce2ffce00688d9402e49fde1c7264223c98d54ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b67fca17a76bead798c04fdd5ea95885340fd3b82be6b4356179356689573303dff7df2442e1360c5bb977b3ece7a0d5827b77a93f5ea07a53416a2499eab6a0
|
7
|
+
data.tar.gz: 2c6063aab10680a1064ab60a33394792508c2e4c19dd13d186b916045f37b873a1d9ce6a79c3ca17e0c7c1cebf650ac26db5ba61e4ecf4f90403ba902044d8c2
|
@@ -2,7 +2,6 @@
|
|
2
2
|
import "@hotwired/stimulus"
|
3
3
|
|
4
4
|
const controllerAttribute = "data-controller"
|
5
|
-
const registeredControllers = {}
|
6
5
|
|
7
6
|
// Eager load all controllers registered beneath the `under` path in the import map to the passed application instance.
|
8
7
|
export function eagerLoadControllersFrom(under, application) {
|
@@ -21,7 +20,7 @@ function registerControllerFromPath(path, under, application) {
|
|
21
20
|
.replace(/\//g, "--")
|
22
21
|
.replace(/_/g, "-")
|
23
22
|
|
24
|
-
if (
|
23
|
+
if (canRegisterController(name, application)) {
|
25
24
|
import(path)
|
26
25
|
.then(module => registerController(name, module, application))
|
27
26
|
.catch(error => console.error(`Failed to register controller: ${name} (${path})`, error))
|
@@ -66,7 +65,7 @@ function extractControllerNamesFrom(element) {
|
|
66
65
|
}
|
67
66
|
|
68
67
|
function loadController(name, under, application) {
|
69
|
-
if (
|
68
|
+
if (canRegisterController(name, application)) {
|
70
69
|
import(controllerFilename(name, under))
|
71
70
|
.then(module => registerController(name, module, application))
|
72
71
|
.catch(error => console.error(`Failed to autoload controller: ${name}`, error))
|
@@ -78,8 +77,11 @@ function controllerFilename(name, under) {
|
|
78
77
|
}
|
79
78
|
|
80
79
|
function registerController(name, module, application) {
|
81
|
-
if (
|
80
|
+
if (canRegisterController(name, application)) {
|
82
81
|
application.register(name, module.default)
|
83
|
-
registeredControllers[name] = true
|
84
82
|
}
|
85
83
|
}
|
84
|
+
|
85
|
+
function canRegisterController(name, application){
|
86
|
+
return !application.router.modulesByIdentifier.has(name)
|
87
|
+
}
|