opal-rails 1.1.1 → 1.1.2
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 +10 -0
- data/app/helpers/opal_helper.rb +6 -5
- data/lib/opal/rails/version.rb +1 -1
- data/spec/helpers/opal_helper_spec.rb +19 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fe52f8b8220d7217cdee145bf089a14e6992c1c187c1a62bba8585433d34081
|
4
|
+
data.tar.gz: 413cd3f385011549dbaa800d3aeb46df5677d0d25e6dfd2e15eedb96f0c58e8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87b789a075dd3f62c76e4dae46686ea291a2949a197a03cfd2c38aac96fc19b16c04e0e8903ed406e5aa9e679969a7e7bde793e6e436c54a63a6b12398eb98fd
|
7
|
+
data.tar.gz: 855c4c73ad06af2c8334aaf7db85c886600210349568b9ced0cc9e49bf952dddd4143c7083fbd69e5f5816cf78e448fa86186606daf0012829edda5063aedc8c
|
data/CHANGELOG.md
CHANGED
@@ -21,6 +21,16 @@ Whitespace conventions:
|
|
21
21
|
|
22
22
|
|
23
23
|
|
24
|
+
## [1.1.2](https://github.com/opal/opal-rails/compare/v1.1.1...v1.1.2) - 2019-09-26
|
25
|
+
|
26
|
+
|
27
|
+
### Fixed
|
28
|
+
|
29
|
+
- Default `skip_onload` to `true` when `javascript_asset_tag` is in debug mode, otherwise some assets may be loaded in the browser after the main source, thus being never loading by the Opal runtime.
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
24
34
|
## [1.1.1](https://github.com/opal/opal-rails/compare/v1.1.0...v1.1.1) - 2019-09-14
|
25
35
|
|
26
36
|
|
data/app/helpers/opal_helper.rb
CHANGED
@@ -10,20 +10,21 @@ module OpalHelper
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def javascript_include_tag(*sources)
|
13
|
-
options = sources.extract_options
|
13
|
+
options = sources.extract_options!.symbolize_keys
|
14
|
+
debug = options[:debug] != false
|
14
15
|
skip_loader = options.delete(:skip_opal_loader)
|
15
|
-
|
16
|
+
force_opal_loader_tag = options.delete(:force_opal_loader_tag) || debug
|
16
17
|
|
17
|
-
return super(*sources, options) if skip_loader
|
18
|
+
return super(*sources, options) if skip_loader && !force_opal_loader_tag
|
18
19
|
|
19
20
|
script_tags = "".html_safe
|
20
21
|
sources.each do |source|
|
21
22
|
load_asset_code = Opal::Sprockets.load_asset(source)
|
22
23
|
loading_code = "if(window.Opal && Opal.modules[#{source.to_json}]){#{load_asset_code}}"
|
23
24
|
|
24
|
-
if
|
25
|
+
if force_opal_loader_tag
|
25
26
|
script_tags << super(source, options)
|
26
|
-
script_tags << javascript_tag(loading_code)
|
27
|
+
script_tags << "\n".html_safe + javascript_tag(loading_code)
|
27
28
|
else
|
28
29
|
script_tags << super(source, options.merge(onload: loading_code))
|
29
30
|
end
|
data/lib/opal/rails/version.rb
CHANGED
@@ -20,17 +20,29 @@ describe OpalHelper, type: :helper do
|
|
20
20
|
# sprockets-rails v3 sets Rails.application.assets to nil in production mode
|
21
21
|
allow(Rails.application).to receive(:assets).and_return(nil)
|
22
22
|
|
23
|
-
loading_code =
|
23
|
+
loading_code = [
|
24
|
+
%<if(window.Opal && Opal.modules["application"]){Opal.loaded(OpalLoaded || []);>,
|
25
|
+
%<Opal.require("application");}>,
|
26
|
+
].join("\n")
|
27
|
+
|
24
28
|
escaped_loading_code = ERB::Util.h loading_code
|
29
|
+
loading_code_in_script_tag = [
|
30
|
+
%(<script>), %(//<![CDATA[), loading_code, %(//]]>), %(</script>),
|
31
|
+
].join("\n")
|
32
|
+
|
33
|
+
expect(helper.javascript_include_tag('application', debug: true)).to include(loading_code_in_script_tag)
|
34
|
+
expect(helper.javascript_include_tag('application', debug: true)).not_to include(escaped_loading_code)
|
25
35
|
|
26
|
-
expect(helper.javascript_include_tag('application', debug: true)).to include(escaped_loading_code)
|
27
36
|
expect(helper.javascript_include_tag('application', debug: false)).to include(escaped_loading_code)
|
37
|
+
expect(helper.javascript_include_tag('application', debug: false)).not_to include(loading_code_in_script_tag)
|
38
|
+
|
28
39
|
expect(helper.javascript_include_tag('application', skip_opal_loader: true)).not_to include(escaped_loading_code)
|
29
|
-
expect(helper.javascript_include_tag('application', skip_opal_loader:
|
40
|
+
expect(helper.javascript_include_tag('application', skip_opal_loader: false)).to include(loading_code_in_script_tag)
|
41
|
+
|
42
|
+
expect(helper.javascript_include_tag('application', force_opal_loader_tag: true, debug: true)).to include(loading_code_in_script_tag)
|
43
|
+
expect(helper.javascript_include_tag('application', force_opal_loader_tag: true, debug: false)).to include(loading_code_in_script_tag)
|
30
44
|
|
31
|
-
expect(helper.javascript_include_tag('application', force_opal_loader_tag: true,
|
32
|
-
expect(helper.javascript_include_tag('application', force_opal_loader_tag: true,
|
33
|
-
expect(helper.javascript_include_tag('application', force_opal_loader_tag: true, skip_opal_loader: true)).not_to include(loading_code)
|
34
|
-
expect(helper.javascript_include_tag('application', force_opal_loader_tag: true, skip_opal_loader: true)).not_to include(loading_code)
|
45
|
+
expect(helper.javascript_include_tag('application', force_opal_loader_tag: true, skip_opal_loader: true)).not_to include(escaped_loading_code)
|
46
|
+
expect(helper.javascript_include_tag('application', force_opal_loader_tag: true, skip_opal_loader: true)).to include(loading_code_in_script_tag)
|
35
47
|
end
|
36
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elia Schito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|