stimulus-rails 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e84e3176b413559951116de8f186f994569dea9ec3c29980fc7a7539a0e4dc25
4
- data.tar.gz: '087c18e56c4dfa3ff52af27fecc85f5853f8c7067774bd55e4e457fe83854831'
3
+ metadata.gz: 294b1fb5168db9b241b1a7f5e05d9bbcea2dc384c55ca0b2b1cef1731ec71c1e
4
+ data.tar.gz: 1f29da6aa09938993859dc7c362509d9bc3b2cab1fd7259dda9a1c2fde9eb7ab
5
5
  SHA512:
6
- metadata.gz: a41fe66b75455c25760f0140c3c02dbc6696d8a0b1c1058f48a7ba03501bf17bd4bc7a1bd5d8113aac46bcdd2ea3d681924835d702814bd3161d8cb2841e9be2
7
- data.tar.gz: c838efdd3448e92ee688686fd11e0208ef3117ae15464ffe1df90b780b935f008f8204c33f77526cb7f711fded3c64c01211c267b5fad62d6fa5e08a790ad2bd
6
+ metadata.gz: 78242453a57877148c68f4250cc8eb9a29f10e064512aee668c56a2b4f8ab71eb8448ae4a62e30af075f559469166b6da91df143ac46ba06a2e5a1af0facbb5c
7
+ data.tar.gz: 004f62719a205a64f1f76d44501960100583e3af56c8f9c32a1a6f71aca4c23a5b39d3a8d0c898d77761c609032feb81c463ee3766ac633ba04690d96c8e7780
@@ -38,7 +38,7 @@ new MutationObserver((mutationsList) => {
38
38
  for (const { attributeName, target, type } of mutationsList) {
39
39
  switch (type) {
40
40
  case "attributes": {
41
- if (attributeName == controllerAttribute && target.hasAttribute(controllerAttribute)) {
41
+ if (attributeName == controllerAttribute && target.getAttribute(controllerAttribute)) {
42
42
  extractControllerNamesFrom(target).forEach(loadController)
43
43
  }
44
44
  }
@@ -0,0 +1,9 @@
1
+ // Load all the controllers within this directory and all subdirectories.
2
+ // Controller files must be named *_controller.js.
3
+
4
+ import { Application } from "stimulus"
5
+ import { definitionsFromContext } from "stimulus/webpack-helpers"
6
+
7
+ const application = Application.start()
8
+ const context = require.context("controllers", true, /_controller\.js$/)
9
+ application.load(definitionsFromContext(context))
@@ -1,11 +1,11 @@
1
1
  module Stimulus::ImportmapHelper
2
2
  def importmap_list_with_stimulus_from(*paths)
3
- [ %("stimulus": "#{asset_path("stimulus/libraries/stimulus")}"), importmap_list_from(*paths) ].join(",\n")
3
+ [ %("stimulus": "#{asset_path("stimulus/libraries/stimulus")}"), importmap_list_from(*paths) ].reject(&:blank?).join(",\n")
4
4
  end
5
5
 
6
6
  def importmap_list_from(*paths)
7
7
  Array(paths).flat_map do |path|
8
- if (absolute_path = Rails.root.join(path)).exist?
8
+ if (absolute_path = absolute_root_of(path)).exist?
9
9
  find_javascript_files_in_tree(absolute_path).collect do |filename|
10
10
  module_filename = filename.relative_path_from(absolute_path)
11
11
  module_name = importmap_module_name_from(module_filename)
@@ -26,4 +26,8 @@ module Stimulus::ImportmapHelper
26
26
  def find_javascript_files_in_tree(path)
27
27
  Dir[path.join("**/*.js{,m}")].collect { |file| Pathname.new(file) }.select(&:file?)
28
28
  end
29
+
30
+ def absolute_root_of(path)
31
+ (pathname = Pathname.new(path)).absolute? ? pathname : Rails.root.join(path)
32
+ end
29
33
  end
@@ -1,3 +1,3 @@
1
1
  module Stimulus
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimulus-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
8
8
  - Javan Mahkmali
9
9
  - David Heinemeier Hansson
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-01-21 00:00:00.000000000 Z
13
+ date: 2021-02-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -26,7 +26,7 @@ dependencies:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  version: 6.0.0
29
- description:
29
+ description:
30
30
  email: david@loudthinking.com
31
31
  executables: []
32
32
  extensions: []
@@ -43,6 +43,7 @@ files:
43
43
  - app/assets/javascripts/stimulus/manifest.js
44
44
  - app/helpers/stimulus/stimulus_helper.rb
45
45
  - lib/install/app/assets/javascripts/controllers/hello_controller.js
46
+ - lib/install/app/assets/javascripts/controllers/index.js
46
47
  - lib/install/app/assets/javascripts/importmap.json.erb
47
48
  - lib/install/application.js
48
49
  - lib/install/stimulus_with_asset_pipeline.rb
@@ -58,7 +59,7 @@ licenses:
58
59
  metadata:
59
60
  homepage_uri: https://stimulus.hotwire.dev
60
61
  source_code_uri: https://github.com/hotwired/stimulus-rails
61
- post_install_message:
62
+ post_install_message:
62
63
  rdoc_options: []
63
64
  require_paths:
64
65
  - lib
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  version: '0'
75
76
  requirements: []
76
77
  rubygems_version: 3.1.2
77
- signing_key:
78
+ signing_key:
78
79
  specification_version: 4
79
80
  summary: A modest JavaScript framework for the HTML you already have.
80
81
  test_files: []