render_async 2.1.8 → 2.1.9
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/.all-contributorsrc +10 -0
- data/.github/CONTRIBUTING.md +40 -0
- data/.gitignore +1 -0
- data/.gitmodules +4 -0
- data/README.md +55 -24
- data/app/views/render_async/_render_async.html.erb +2 -1
- data/app/views/render_async/_request_jquery.js.erb +10 -0
- data/app/views/render_async/_request_vanilla.js.erb +13 -0
- data/bin/integration-tests +7 -0
- data/lib/render_async/configuration.rb +2 -1
- data/lib/render_async/version.rb +1 -1
- data/lib/render_async/view_helper.rb +3 -3
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6efd10ad97f50cae5b58a0ff6042df5c0b9f5ed0b27ca1a498f4cdb84172ab79
|
4
|
+
data.tar.gz: 8daab586cb6b11d66bc873e12929ee2bb1162a6b5578e343ddeb6f03c1094c71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aaa98a754f9cbce70521702793d6307fbb976b064a9b981a7a5c43db5dd12527cfa81f5a07269476958f12ae0f0f2a79a4038236146cda6a2bfc2e23b3c36fbf
|
7
|
+
data.tar.gz: db95a549cd0d1f3ee086ad35634cf53f94e615de679dd201a543432337e99de43cf9b080d9c10296a0e1e2391e48bedf16717fd868fe7ec7ecae3c35ce7bb384
|
data/.all-contributorsrc
CHANGED
@@ -214,6 +214,16 @@
|
|
214
214
|
"contributions": [
|
215
215
|
"doc"
|
216
216
|
]
|
217
|
+
},
|
218
|
+
{
|
219
|
+
"login": "Mbuckley0",
|
220
|
+
"name": "Mitchell Buckley",
|
221
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/11203679?v=4",
|
222
|
+
"profile": "https://github.com/Mbuckley0",
|
223
|
+
"contributions": [
|
224
|
+
"code",
|
225
|
+
"doc"
|
226
|
+
]
|
217
227
|
}
|
218
228
|
],
|
219
229
|
"repoType": "github"
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# :pray: Contributing
|
2
|
+
|
3
|
+
Thank you for considering or deciding to contribute, this is much appreciated!
|
4
|
+
Any kind of bug reports and pull requests are encouraged and welcome on GitHub at
|
5
|
+
https://github.com/renderedtext/render_async.
|
6
|
+
|
7
|
+
## :inbox_tray: Installing dependencies
|
8
|
+
|
9
|
+
You can install all needed dependencies by running `bin/setup`.
|
10
|
+
|
11
|
+
## :runner: Running RSpec tests
|
12
|
+
|
13
|
+
You can run either `rake spec` or `bundle exec rspec` to run all the RSpec tests
|
14
|
+
in the project.
|
15
|
+
|
16
|
+
## :running_woman: Running integration tests
|
17
|
+
|
18
|
+
There is a simple command `bin/integration-tests` which sets up 2 submodules,
|
19
|
+
and runs Cucumber features in them.
|
20
|
+
|
21
|
+
There are 2 submodules for render_async. The submodules are Rails 5 and Rails 6
|
22
|
+
projects which are located in:
|
23
|
+
|
24
|
+
- `spec/fixtures/rails-5-base-app`, and
|
25
|
+
- `spec/fixtures/rails-6-base-app`.
|
26
|
+
|
27
|
+
You can find [Rails 5 base app here](https://github.com/nikolalsvk/rails-5-base-app/tree/render-async),
|
28
|
+
and the [Rails 6 base app here](https://github.com/nikolalsvk/rails-6-base-app/tree/render-async).
|
29
|
+
|
30
|
+
Each of them have different use cases of render_async defined in `app/views/render_asyncs/_use_cases.html.erb` in their repos.
|
31
|
+
All the feature tests are inside `features/render_async.feature` and `features/render_async_jquery.feature` files.
|
32
|
+
|
33
|
+
If you are adding one or more feature tests or use cases, make sure to make a
|
34
|
+
PR on those repos as well and include them in the PR on the render_async repo.
|
35
|
+
|
36
|
+
## :sos: Need help?
|
37
|
+
|
38
|
+
Got any issues or difficulties?
|
39
|
+
Join [render_async's Discord channel](https://discord.gg/SPfbeRm)
|
40
|
+
and ask questions there. We will try to respond to you as quickly as possible.
|
data/.gitignore
CHANGED
data/.gitmodules
CHANGED
@@ -2,3 +2,7 @@
|
|
2
2
|
path = spec/fixtures/rails-5-base-app
|
3
3
|
url = git@github.com:nikolalsvk/rails-5-base-app.git
|
4
4
|
branch = render-async
|
5
|
+
[submodule "spec/fixtures/rails-6-base-app"]
|
6
|
+
path = spec/fixtures/rails-6-base-app
|
7
|
+
url = git@github.com:nikolalsvk/rails-6-base-app.git
|
8
|
+
branch = render-async
|
data/README.md
CHANGED
@@ -82,7 +82,7 @@ And then execute:
|
|
82
82
|
<%= render_async comment_stats_path %>
|
83
83
|
```
|
84
84
|
|
85
|
-
2. Then create a route
|
85
|
+
2. Then create a route for it `config/routes.rb`:
|
86
86
|
```ruby
|
87
87
|
get :comment_stats, controller: :comments
|
88
88
|
```
|
@@ -130,6 +130,7 @@ Advanced usage includes information on different options, such as:
|
|
130
130
|
- [Caching](#caching)
|
131
131
|
- [Doing non-GET requests](#doing-non-get-requests)
|
132
132
|
- [Using with Turbolinks](#using-with-turbolinks)
|
133
|
+
- [Using with Turbo](#using-with-turbo)
|
133
134
|
- [Using with respond_to and JS format](#using-with-respond_to-and-js-format)
|
134
135
|
- [Nested async renders](#nested-async-renders)
|
135
136
|
- [Customizing the content_for name](#customizing-the-content_for-name)
|
@@ -198,7 +199,7 @@ Rendered code in the view:
|
|
198
199
|
</div>
|
199
200
|
```
|
200
201
|
|
201
|
-
> :bulb: You can enable `nonce` to be set everywhere by using [configuration option](#configuration-
|
202
|
+
> :bulb: You can enable `nonce` to be set everywhere by using [configuration option](#configuration-options) render_async provides.
|
202
203
|
|
203
204
|
### Passing in an HTML element name
|
204
205
|
|
@@ -291,7 +292,7 @@ document.addEventListener("users-loaded", function(event) {
|
|
291
292
|
### Using default events
|
292
293
|
|
293
294
|
`render_async` will fire the event `render_async_load` when an async partial
|
294
|
-
has loaded and rendered on page.
|
295
|
+
has loaded and rendered on the page.
|
295
296
|
|
296
297
|
In case there is an error, the event `render_async_error` will fire instead.
|
297
298
|
|
@@ -384,7 +385,7 @@ failure. In the end, if the request is still failing after 5th time, it will
|
|
384
385
|
dispatch a [default error event](#using-default-events).
|
385
386
|
|
386
387
|
> :candy: If you are catching an event after an error, you can get `retryCount` from
|
387
|
-
the event. `retryCount` will have number of retries it took before the event was dispatched.
|
388
|
+
the event. `retryCount` will have the number of retries it took before the event was dispatched.
|
388
389
|
|
389
390
|
Here is an example on how to get `retryCount`:
|
390
391
|
|
@@ -415,7 +416,7 @@ do this by doing the following:
|
|
415
416
|
```
|
416
417
|
|
417
418
|
This will trigger `render_async` to load the `comments_path` when you click the `#comments-button` element.
|
418
|
-
If you want to remove event once it's triggered, you can pass `once: true` in the toggle options.
|
419
|
+
If you want to remove an event once it's triggered, you can pass `once: true` in the toggle options.
|
419
420
|
The `once` option is false (`nil`) by default.
|
420
421
|
|
421
422
|
You can also pass in a placeholder before the `render_async` is triggered. That
|
@@ -460,7 +461,7 @@ loading" button.
|
|
460
461
|
### Polling
|
461
462
|
|
462
463
|
You can call `render_async` with interval argument. This will make render_async
|
463
|
-
call specified path at specified interval.
|
464
|
+
call specified path at the specified interval.
|
464
465
|
|
465
466
|
By doing this:
|
466
467
|
```erb
|
@@ -470,8 +471,8 @@ You are telling `render_async` to fetch comments_path every 5 seconds.
|
|
470
471
|
|
471
472
|
This can be handy if you want to enable polling for a specific URL.
|
472
473
|
|
473
|
-
> :warning: By passing interval to `render_async`, initial container element
|
474
|
-
> will remain in HTML tree
|
474
|
+
> :warning: By passing interval to `render_async`, the initial container element
|
475
|
+
> will remain in the HTML tree and it will not be replaced with request response.
|
475
476
|
> You can handle how that container element is rendered and its style by
|
476
477
|
> [passing in an HTML element name](#passing-in-an-html-element-name) and
|
477
478
|
> [HTML element class](#passing-in-a-container-class-name).
|
@@ -483,8 +484,8 @@ First one is pretty simple, and it involves using the [toggle](#toggle-event)
|
|
483
484
|
feature. To do this, you can follow instructions in the
|
484
485
|
[control polling with a toggle section](#control-polling-with-a-toggle).
|
485
486
|
|
486
|
-
|
487
|
-
container element. From your code, you can emit following events:
|
487
|
+
The second option is more advanced and it involves emitting events to the `render_async`'s
|
488
|
+
container element. From your code, you can emit the following events:
|
488
489
|
- 'async-stop' - this will stop polling
|
489
490
|
- 'async-start' - this will start polling.
|
490
491
|
|
@@ -522,13 +523,13 @@ An example of how you can do this looks like this:
|
|
522
523
|
```
|
523
524
|
|
524
525
|
We are rendering two buttons - "Stop polling" and "Start polling". Then, we
|
525
|
-
attach event listener to catch any clicking on the buttons. When the buttons
|
526
|
-
are clicked, we either stop the polling
|
526
|
+
attach an event listener to catch any clicking on the buttons. When the buttons
|
527
|
+
are clicked, we either stop the polling or start the polling, depending on which
|
527
528
|
button a user clicks.
|
528
529
|
|
529
530
|
### Handling errors
|
530
531
|
|
531
|
-
`render_async`
|
532
|
+
`render_async` lets you handle errors by allowing you to pass in `error_message`
|
532
533
|
and `error_event_name`.
|
533
534
|
|
534
535
|
- `error_message`
|
@@ -615,7 +616,7 @@ end
|
|
615
616
|
```
|
616
617
|
|
617
618
|
This way, you're not breaking Turbolinks flow of loading or reloading a page.
|
618
|
-
It
|
619
|
+
It is more efficient than the next option below.
|
619
620
|
|
620
621
|
Another option:
|
621
622
|
If you want, you can tell Turbolinks to reload your `render_async` call as follows:
|
@@ -626,8 +627,38 @@ If you want, you can tell Turbolinks to reload your `render_async` call as follo
|
|
626
627
|
|
627
628
|
This will reload the whole page with Turbolinks.
|
628
629
|
|
629
|
-
> :bulb:
|
630
|
-
the `<
|
630
|
+
> :bulb: If Turbolinks is misbehaving in some way, make sure to put `<%= content_for :render_async %>` in your base view file in
|
631
|
+
the `<body>` and not the `<head>`.
|
632
|
+
|
633
|
+
### Using with Turbo
|
634
|
+
|
635
|
+
On Turbo applications, you may experience caching issues when navigating
|
636
|
+
away from, and then back to, a page with a `render_async` call on it. This will
|
637
|
+
likely show up as an empty div.
|
638
|
+
|
639
|
+
If you're using Turbo, you can resolve this by setting Turbo
|
640
|
+
configuration of `render_async` to true:
|
641
|
+
|
642
|
+
```rb
|
643
|
+
RenderAsync.configure do |config|
|
644
|
+
config.turbo = true # Enable this option if you are using Turbo
|
645
|
+
end
|
646
|
+
```
|
647
|
+
|
648
|
+
This way, you're not breaking Turbos flow of loading or reloading a page.
|
649
|
+
It is more efficient than the next option below.
|
650
|
+
|
651
|
+
Another option:
|
652
|
+
If you want, you can tell Turbo to reload your `render_async` call as follows:
|
653
|
+
|
654
|
+
```erb
|
655
|
+
<%= render_async events_path, 'data-turbo-track': 'reload' %>
|
656
|
+
```
|
657
|
+
|
658
|
+
This will reload the whole page with Turbo.
|
659
|
+
|
660
|
+
> :bulb: If Turbo is misbehaving in some way, make sure to put `<%= content_for :render_async %>` in your base view file in
|
661
|
+
the `<body>` and not the `<head>`.
|
631
662
|
|
632
663
|
### Using with respond_to and JS format
|
633
664
|
|
@@ -646,7 +677,7 @@ def comment_stats
|
|
646
677
|
end
|
647
678
|
```
|
648
679
|
|
649
|
-
When you do this, Rails will
|
680
|
+
When you do this, Rails will sometimes set the response's `Content-Type` header
|
650
681
|
to `text/javascript`. This causes the partial not to be rendered in the HTML.
|
651
682
|
This usually happens when there's browser caching.
|
652
683
|
|
@@ -712,8 +743,9 @@ You can configure it by doing the following anywhere before you call
|
|
712
743
|
RenderAsync.configure do |config|
|
713
744
|
config.jquery = true # This will render jQuery code, and skip Vanilla JS code. The default value is false.
|
714
745
|
config.turbolinks = true # Enable this option if you are using Turbolinks 5+. The default value is false.
|
746
|
+
config.turbo = true # Enable this option if you are using Turbo. The default value is false.
|
715
747
|
config.replace_container = false # Set to false if you want to keep the placeholder div element from render_async. The default value is true.
|
716
|
-
config.nonces = true # Set to true if you want render_async's javascript_tag to
|
748
|
+
config.nonces = true # Set to true if you want render_async's javascript_tag always to receive nonce: true. The default value is false.
|
717
749
|
end
|
718
750
|
```
|
719
751
|
|
@@ -726,7 +758,8 @@ RenderAsync.configuration.jquery = true
|
|
726
758
|
Aside from configuring whether the gem relies on jQuery or VanillaJS, you can
|
727
759
|
configure other options:
|
728
760
|
|
729
|
-
- `turbolinks` option - If you are using Turbolinks 5+, you should enable this option since it supports Turbolinks way of loading data. The default value for this
|
761
|
+
- `turbolinks` option - If you are using Turbolinks 5+, you should enable this option since it supports Turbolinks way of loading data. The default value for this option is false.
|
762
|
+
- `turbo` option - If you are using Turbo, you should enable this option since it supports Turbo way of loading data. The default value for this option is false.
|
730
763
|
- `replace_container` option - If you want render_async to replace its container with the request response, turn this on. You can turn this on globally for all render_async calls, but if you use this option in a specific render_async call, it will override the global configuration. The default value is true.
|
731
764
|
- `nonces` - If you need to pass in `nonce: true` to the `javascript_tag` in your application, it might make sense for you to turn this on globally for all render_async calls. To read more about nonces, check out [Rails' official guide on security](https://edgeguides.rubyonrails.org/security.html). The default value is false.
|
732
765
|
|
@@ -735,7 +768,7 @@ configure other options:
|
|
735
768
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
736
769
|
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
737
770
|
prompt that will allow you to experiment. To run integration tests, use
|
738
|
-
`bin/integration-tests`.
|
771
|
+
`bin/integration-tests`. For more information, check out [CONTRIBUTING](.github/CONTRIBUTING.md) file, please.
|
739
772
|
|
740
773
|
Got any questions or comments about development (or anything else)?
|
741
774
|
Join [render_async's Discord channel](https://discord.gg/SPfbeRm)
|
@@ -743,9 +776,7 @@ and let's make `render_async` even better!
|
|
743
776
|
|
744
777
|
## :pray: Contributing
|
745
778
|
|
746
|
-
|
747
|
-
Any kind of bug reports and pull requests are encouraged and welcome on GitHub at
|
748
|
-
https://github.com/renderedtext/render_async.
|
779
|
+
Check out [CONTRIBUTING](.github/CONTRIBUTING.md) file, please.
|
749
780
|
|
750
781
|
Got any issues or difficulties?
|
751
782
|
Join [render_async's Discord channel](https://discord.gg/SPfbeRm)
|
@@ -765,7 +796,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
|
|
765
796
|
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
766
797
|
| [<img src="https://avatars3.githubusercontent.com/u/50223?v=4" width="100px;"/><br /><sub><b>Ernest Surudo</b></sub>](http://elsurudo.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=elsurudo "Code") | [<img src="https://avatars1.githubusercontent.com/u/334809?v=4" width="100px;"/><br /><sub><b>Kurtis Rainbolt-Greene</b></sub>](https://kurtis.rainbolt-greene.online)<br />[💻](https://github.com/renderedtext/render_async/commits?author=krainboltgreene "Code") | [<img src="https://avatars2.githubusercontent.com/u/59744?v=4" width="100px;"/><br /><sub><b>Richard Schneeman</b></sub>](https://www.schneems.com)<br />[📖](https://github.com/renderedtext/render_async/commits?author=schneems "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/75705?v=4" width="100px;"/><br /><sub><b>Richard Venneman</b></sub>](https://www.cityspotters.com)<br />[📖](https://github.com/renderedtext/render_async/commits?author=richardvenneman "Documentation") | [<img src="https://avatars3.githubusercontent.com/u/381395?v=4" width="100px;"/><br /><sub><b>Filipe W. Lima</b></sub>](https://github.com/filipewl)<br />[📖](https://github.com/renderedtext/render_async/commits?author=filipewl "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/3135638?v=4" width="100px;"/><br /><sub><b>Jesús Eduardo Clemens Chong</b></sub>](https://github.com/eclemens)<br />[💻](https://github.com/renderedtext/render_async/commits?author=eclemens "Code") | [<img src="https://avatars3.githubusercontent.com/u/1935686?v=4" width="100px;"/><br /><sub><b>René Klačan</b></sub>](https://github.com/reneklacan)<br />[💻](https://github.com/renderedtext/render_async/commits?author=reneklacan "Code") |
|
767
798
|
| [<img src="https://avatars1.githubusercontent.com/u/1313442?v=4" width="100px;"/><br /><sub><b>Gil Gomes</b></sub>](http://gilgomes.com.br)<br />[📖](https://github.com/renderedtext/render_async/commits?author=gil27 "Documentation") | [<img src="https://avatars0.githubusercontent.com/u/6081795?v=4" width="100px;"/><br /><sub><b>Khoa Nguyen</b></sub>](https://github.com/ThanhKhoaIT)<br />[💻](https://github.com/renderedtext/render_async/commits?author=ThanhKhoaIT "Code") [📖](https://github.com/renderedtext/render_async/commits?author=ThanhKhoaIT "Documentation") | [<img src="https://avatars2.githubusercontent.com/u/8645918?v=4" width="100px;"/><br /><sub><b>Preet Sethi</b></sub>](https://www.linkedin.com/in/preetsethila/)<br />[💻](https://github.com/renderedtext/render_async/commits?author=preetsethi "Code") | [<img src="https://avatars3.githubusercontent.com/u/11586335?v=4" width="100px;"/><br /><sub><b>fangxing</b></sub>](https://github.com/fffx)<br />[💻](https://github.com/renderedtext/render_async/commits?author=fffx "Code") | [<img src="https://avatars3.githubusercontent.com/u/1191418?v=4" width="100px;"/><br /><sub><b>Emmanuel Pire</b></sub>](http://blog.lipsumarium.com)<br />[💻](https://github.com/renderedtext/render_async/commits?author=lipsumar "Code") [📖](https://github.com/renderedtext/render_async/commits?author=lipsumar "Documentation") | [<img src="https://avatars1.githubusercontent.com/u/615509?v=4" width="100px;"/><br /><sub><b>Maxim Geerinck</b></sub>](https://github.com/maximgeerinck)<br />[💻](https://github.com/renderedtext/render_async/commits?author=maximgeerinck "Code") | [<img src="https://avatars1.githubusercontent.com/u/251706?v=4" width="100px;"/><br /><sub><b>Don</b></sub>](https://github.com/vanboom)<br />[💻](https://github.com/renderedtext/render_async/commits?author=vanboom "Code") |
|
768
|
-
| [<img src="https://avatars0.githubusercontent.com/u/998682?v=4" width="100px;"/><br /><sub><b>villu164</b></sub>](https://github.com/villu164)<br />[📖](https://github.com/renderedtext/render_async/commits?author=villu164 "Documentation") |
|
799
|
+
| [<img src="https://avatars0.githubusercontent.com/u/998682?v=4" width="100px;"/><br /><sub><b>villu164</b></sub>](https://github.com/villu164)<br />[📖](https://github.com/renderedtext/render_async/commits?author=villu164 "Documentation") | [<img src="https://avatars.githubusercontent.com/u/11203679?v=4" width="100px;"/><br /><sub><b>Mitchell Buckley</b></sub>](https://github.com/Mbuckley0)<br />[💻](https://github.com/renderedtext/render_async/commits?author=Mbuckley0 "Code") [📖](https://github.com/renderedtext/render_async/commits?author=Mbuckley0 "Documentation") |
|
769
800
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
770
801
|
|
771
802
|
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
|
@@ -20,7 +20,8 @@
|
|
20
20
|
retry_count: retry_count,
|
21
21
|
retry_delay: retry_delay,
|
22
22
|
interval: interval,
|
23
|
-
turbolinks: RenderAsync.configuration.turbolinks
|
23
|
+
turbolinks: RenderAsync.configuration.turbolinks,
|
24
|
+
turbo: RenderAsync.configuration.turbo} %>
|
24
25
|
|
25
26
|
<% if RenderAsync.configuration.jquery %>
|
26
27
|
<%= render partial: 'render_async/request_jquery',
|
@@ -5,6 +5,11 @@ if (window.jQuery) {
|
|
5
5
|
return;
|
6
6
|
}
|
7
7
|
<% end %>
|
8
|
+
<% if turbo %>
|
9
|
+
if (document.documentElement.hasAttribute("data-turbo-preview")) {
|
10
|
+
return;
|
11
|
+
}
|
12
|
+
<% end %>
|
8
13
|
function createEvent(name, container) {
|
9
14
|
var event = undefined;
|
10
15
|
if (typeof(Event) === 'function') {
|
@@ -24,6 +29,8 @@ if (window.jQuery) {
|
|
24
29
|
} else {
|
25
30
|
<% if turbolinks %>
|
26
31
|
$(document).one('turbolinks:load', callback);
|
32
|
+
<% elsif turbo %>
|
33
|
+
$(document).one('turbo:load', callback);
|
27
34
|
<% else %>
|
28
35
|
$(document).ready(callback);
|
29
36
|
<% end %>
|
@@ -137,6 +144,9 @@ if (window.jQuery) {
|
|
137
144
|
<% if turbolinks %>
|
138
145
|
$(document).one('turbolinks:visit', _clearRenderAsyncInterval);
|
139
146
|
<% end %>
|
147
|
+
<% if turbo %>
|
148
|
+
$(document).one('turbo:visit', _clearRenderAsyncInterval);
|
149
|
+
<% end %>
|
140
150
|
<% end %>
|
141
151
|
|
142
152
|
<% if !replace_container %>
|
@@ -4,6 +4,11 @@
|
|
4
4
|
return;
|
5
5
|
}
|
6
6
|
<% end %>
|
7
|
+
<% if turbo %>
|
8
|
+
if (document.documentElement.hasAttribute("data-turbo-preview")) {
|
9
|
+
return;
|
10
|
+
}
|
11
|
+
<% end %>
|
7
12
|
function createEvent(name, container) {
|
8
13
|
var event = undefined;
|
9
14
|
if (typeof(Event) === 'function') {
|
@@ -22,6 +27,11 @@
|
|
22
27
|
e.target.removeEventListener(e.type, arguments.callee);
|
23
28
|
callback();
|
24
29
|
});
|
30
|
+
<% elsif turbo %>
|
31
|
+
document.addEventListener("turbo:load", function(e) {
|
32
|
+
e.target.removeEventListener(e.type, arguments.callee);
|
33
|
+
callback();
|
34
|
+
});
|
25
35
|
<% else %>
|
26
36
|
document.addEventListener("DOMContentLoaded", callback);
|
27
37
|
<% end %>
|
@@ -147,6 +157,9 @@
|
|
147
157
|
<% if turbolinks %>
|
148
158
|
document.addEventListener("turbolinks:visit", _clearRenderAsyncInterval)
|
149
159
|
<% end %>
|
160
|
+
<% if turbo %>
|
161
|
+
document.addEventListener("turbo:visit", _clearRenderAsyncInterval)
|
162
|
+
<% end %>
|
150
163
|
<% end %>
|
151
164
|
|
152
165
|
<% if !replace_container %>
|
data/bin/integration-tests
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module RenderAsync
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :jquery, :turbolinks, :replace_container, :nonces
|
3
|
+
attr_accessor :jquery, :turbolinks, :turbo, :replace_container, :nonces
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@jquery = false
|
7
7
|
@turbolinks = false
|
8
|
+
@turbo = false
|
8
9
|
@replace_container = true
|
9
10
|
@nonces = false
|
10
11
|
end
|
data/lib/render_async/version.rb
CHANGED
@@ -44,7 +44,7 @@ module RenderAsync
|
|
44
44
|
def html_options(options)
|
45
45
|
set_options = options.delete(:html_options) || {}
|
46
46
|
|
47
|
-
set_options[:nonce] =
|
47
|
+
set_options[:nonce] = configuration.nonces if set_options[:nonce].nil?
|
48
48
|
|
49
49
|
set_options
|
50
50
|
end
|
@@ -85,10 +85,10 @@ module RenderAsync
|
|
85
85
|
def replace_container(options)
|
86
86
|
return options[:replace_container] unless options[:replace_container].nil?
|
87
87
|
|
88
|
-
|
88
|
+
configuration.replace_container
|
89
89
|
end
|
90
90
|
|
91
|
-
def
|
91
|
+
def configuration
|
92
92
|
RenderAsync.configuration
|
93
93
|
end
|
94
94
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render_async
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Grubbe
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -61,6 +61,7 @@ extensions: []
|
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
63
|
- ".all-contributorsrc"
|
64
|
+
- ".github/CONTRIBUTING.md"
|
64
65
|
- ".github/FUNDING.yml"
|
65
66
|
- ".gitignore"
|
66
67
|
- ".gitmodules"
|