You've already forked php-flasher
mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 23:17:47 +01:00
Merge pull request #168 from php-flasher/issue-161
feat(livewire): Remove .fl-no-cache elements before caching snapshot
This commit is contained in:
@@ -50,7 +50,7 @@ return array(
|
||||
| field of this option.
|
||||
*/
|
||||
'root_script' => array(
|
||||
'cdn' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.1/dist/flasher.min.js',
|
||||
'cdn' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.2/dist/flasher.min.js',
|
||||
'local' => '/vendor/flasher/flasher.min.js',
|
||||
),
|
||||
|
||||
@@ -70,7 +70,7 @@ return array(
|
||||
| the stylesheet file in the 'local' field of this option.
|
||||
*/
|
||||
'styles' => array(
|
||||
'cdn' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.1/dist/flasher.min.css',
|
||||
'cdn' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.2/dist/flasher.min.css',
|
||||
'local' => '/vendor/flasher/flasher.min.css',
|
||||
),
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
return array(
|
||||
'scripts' => array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.1/dist/flasher-noty.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.2/dist/flasher-noty.min.js',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-noty.min.js',
|
||||
@@ -16,7 +16,7 @@ return array(
|
||||
),
|
||||
'styles' => array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.1/dist/flasher-noty.min.css',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.2/dist/flasher-noty.min.css',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-noty.min.css',
|
||||
|
||||
@@ -18,7 +18,7 @@ class NotyPlugin extends Plugin
|
||||
{
|
||||
return array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.1/dist/flasher-noty.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.2/dist/flasher-noty.min.js',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-noty.min.js',
|
||||
@@ -33,7 +33,7 @@ class NotyPlugin extends Plugin
|
||||
{
|
||||
return array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.1/dist/flasher-noty.min.css',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.2/dist/flasher-noty.min.css',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-noty.min.css',
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,12 +1,12 @@
|
||||
flasher_noty:
|
||||
scripts:
|
||||
cdn:
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.1/dist/flasher-noty.min.js'
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.2/dist/flasher-noty.min.js'
|
||||
local:
|
||||
- '/vendor/flasher/flasher-noty.min.js'
|
||||
|
||||
styles:
|
||||
cdn:
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.1/dist/flasher-noty.min.css'
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-noty@1.3.2/dist/flasher-noty.min.css'
|
||||
local:
|
||||
- '/vendor/flasher/flasher-noty.min.css'
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
return array(
|
||||
'scripts' => array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.1/dist/flasher-notyf.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.2/dist/flasher-notyf.min.js',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-notyf.min.js',
|
||||
@@ -16,7 +16,7 @@ return array(
|
||||
),
|
||||
'styles' => array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.1/dist/flasher-notyf.min.css',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.2/dist/flasher-notyf.min.css',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-notyf.min.css',
|
||||
|
||||
@@ -18,7 +18,7 @@ class NotyfPlugin extends Plugin
|
||||
{
|
||||
return array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.1/dist/flasher-notyf.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.2/dist/flasher-notyf.min.js',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-notyf.min.js',
|
||||
@@ -33,7 +33,7 @@ class NotyfPlugin extends Plugin
|
||||
{
|
||||
return array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.1/dist/flasher-notyf.min.css',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.2/dist/flasher-notyf.min.css',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-notyf.min.css',
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,11 +1,11 @@
|
||||
flasher_notyf:
|
||||
scripts:
|
||||
cdn:
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.1/dist/flasher-notyf.min.js'
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.2/dist/flasher-notyf.min.js'
|
||||
local:
|
||||
- '/vendor/flasher/flasher-notyf.min.js'
|
||||
styles:
|
||||
cdn:
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.1/dist/flasher-notyf.min.css'
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-notyf@1.3.2/dist/flasher-notyf.min.css'
|
||||
local:
|
||||
- '/vendor/flasher/flasher-notyf.min.css'
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
return array(
|
||||
'scripts' => array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.1/dist/flasher-pnotify.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.2/dist/flasher-pnotify.min.js',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-pnotify.min.js',
|
||||
@@ -16,7 +16,7 @@ return array(
|
||||
),
|
||||
'styles' => array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.1/dist/flasher-pnotify.min.css',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.2/dist/flasher-pnotify.min.css',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-pnotify.min.css',
|
||||
|
||||
@@ -18,7 +18,7 @@ class PnotifyPlugin extends Plugin
|
||||
{
|
||||
return array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.1/dist/flasher-pnotify.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.2/dist/flasher-pnotify.min.js',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-pnotify.min.js',
|
||||
@@ -33,7 +33,7 @@ class PnotifyPlugin extends Plugin
|
||||
{
|
||||
return array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.1/dist/flasher-pnotify.min.css',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.2/dist/flasher-pnotify.min.css',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-pnotify.min.css',
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,12 +1,12 @@
|
||||
flasher_pnotify:
|
||||
scripts:
|
||||
cdn:
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.1/dist/flasher-pnotify.min.js'
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.2/dist/flasher-pnotify.min.js'
|
||||
local:
|
||||
- '/vendor/flasher/flasher-pnotify.min.js'
|
||||
|
||||
styles:
|
||||
cdn:
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.1/dist/flasher-pnotify.min.css'
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-pnotify@1.3.2/dist/flasher-pnotify.min.css'
|
||||
local:
|
||||
- '/vendor/flasher/flasher-pnotify.min.css'
|
||||
|
||||
@@ -45,7 +45,7 @@ final class FlasherPlugin extends Plugin
|
||||
public function getRootScript()
|
||||
{
|
||||
return array(
|
||||
'cdn' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.1/dist/flasher.min.js',
|
||||
'cdn' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.2/dist/flasher.min.js',
|
||||
'local' => '/vendor/flasher/flasher.min.js',
|
||||
);
|
||||
}
|
||||
@@ -67,7 +67,7 @@ final class FlasherPlugin extends Plugin
|
||||
{
|
||||
return array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.1/dist/flasher.min.css',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.2/dist/flasher.min.css',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher.min.css',
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -29,6 +29,7 @@ final class HtmlPresenter implements PresenterInterface
|
||||
|
||||
$rootScript = $response->getRootScript();
|
||||
$placeHolder = self::FLASHER_FLASH_BAG_PLACE_HOLDER;
|
||||
$livewireListener = $this->getLivewireListenerScript();
|
||||
|
||||
return <<<JAVASCRIPT
|
||||
<script type="text/javascript" class="flasher-js">
|
||||
@@ -84,6 +85,8 @@ final class HtmlPresenter implements PresenterInterface
|
||||
document.addEventListener('flasher:render', function (event) {
|
||||
render(event.detail);
|
||||
});
|
||||
|
||||
{$livewireListener}
|
||||
}
|
||||
|
||||
if (window.hasOwnProperty('flasher') || !rootScript || document.querySelector('script[src="' + rootScript + '"]')) {
|
||||
@@ -100,6 +103,27 @@ final class HtmlPresenter implements PresenterInterface
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
JAVASCRIPT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the script for Livewire event handling.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getLivewireListenerScript()
|
||||
{
|
||||
if (!class_exists('Livewire\LivewireManager')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return <<<JAVASCRIPT
|
||||
document.addEventListener('livewire:navigating', function () {
|
||||
var elements = document.querySelectorAll('.fl-no-cache');
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
elements[i].remove();
|
||||
}
|
||||
});
|
||||
JAVASCRIPT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
return array(
|
||||
'scripts' => array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-sweetalert@1.3.1/dist/flasher-sweetalert.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-sweetalert@1.3.2/dist/flasher-sweetalert.min.js',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-sweetalert.min.js',
|
||||
@@ -16,7 +16,7 @@ return array(
|
||||
),
|
||||
'styles' => array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-sweetalert@1.3.1/dist/flasher-sweetalert.min.css',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-sweetalert@1.3.2/dist/flasher-sweetalert.min.css',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-sweetalert.min.css',
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -23,7 +23,7 @@ class SweetAlertPlugin extends Plugin
|
||||
{
|
||||
return array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-sweetalert@1.3.1/dist/flasher-sweetalert.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-sweetalert@1.3.2/dist/flasher-sweetalert.min.js',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-sweetalert.min.js',
|
||||
@@ -38,7 +38,7 @@ class SweetAlertPlugin extends Plugin
|
||||
{
|
||||
return array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-sweetalert@1.3.1/dist/flasher-sweetalert.min.css',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-sweetalert@1.3.2/dist/flasher-sweetalert.min.css',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-sweetalert.min.css',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
flasher_sweetalert:
|
||||
scripts:
|
||||
cdn:
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-sweetalert@1.3.1/dist/flasher-sweetalert.min.js'
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-sweetalert@1.3.2/dist/flasher-sweetalert.min.js'
|
||||
local:
|
||||
- '/vendor/flasher/flasher-sweetalert.min.js'
|
||||
|
||||
@@ -41,7 +41,7 @@ flasher:
|
||||
# field of this option.
|
||||
#
|
||||
root_script:
|
||||
cdn: 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.1/dist/flasher.min.js'
|
||||
cdn: 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.2/dist/flasher.min.js'
|
||||
local: '/vendor/flasher/flasher.min.js'
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
@@ -59,7 +59,7 @@ flasher:
|
||||
# the stylesheet file in the 'local' field of this option.
|
||||
#
|
||||
styles:
|
||||
cdn: 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.1/dist/flasher.min.css'
|
||||
cdn: 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.2/dist/flasher.min.css'
|
||||
local: '/vendor/flasher/flasher.min.css'
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
@@ -9,7 +9,7 @@ return array(
|
||||
'scripts' => array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/jquery@3.6.3/dist/jquery.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.1/dist/flasher-toastr.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.2/dist/flasher-toastr.min.js',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/jquery.min.js',
|
||||
@@ -18,7 +18,7 @@ return array(
|
||||
),
|
||||
'styles' => array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.1/dist/flasher-toastr.min.css',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.2/dist/flasher-toastr.min.css',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-toastr.min.css',
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -19,7 +19,7 @@ class ToastrPlugin extends Plugin
|
||||
return array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/jquery@3.7.0/dist/jquery.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.1/dist/flasher-toastr.min.js',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.2/dist/flasher-toastr.min.js',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/jquery.min.js',
|
||||
@@ -35,7 +35,7 @@ class ToastrPlugin extends Plugin
|
||||
{
|
||||
return array(
|
||||
'cdn' => array(
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.1/dist/flasher-toastr.min.css',
|
||||
'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.2/dist/flasher-toastr.min.css',
|
||||
),
|
||||
'local' => array(
|
||||
'/vendor/flasher/flasher-toastr.min.css',
|
||||
|
||||
@@ -2,13 +2,13 @@ flasher_toastr:
|
||||
scripts:
|
||||
cdn:
|
||||
- 'https://cdn.jsdelivr.net/npm/jquery@3.6.3/dist/jquery.min.js'
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.1/dist/flasher-toastr.min.js'
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.2/dist/flasher-toastr.min.js'
|
||||
local:
|
||||
- '/vendor/flasher/jquery.min.js'
|
||||
- '/vendor/flasher/flasher-toastr.min.js'
|
||||
|
||||
styles:
|
||||
cdn:
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.1/dist/flasher-toastr.min.css'
|
||||
- 'https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@1.3.2/dist/flasher-toastr.min.css'
|
||||
local:
|
||||
- '/vendor/flasher/flasher-toastr.min.css'
|
||||
|
||||
@@ -46,7 +46,7 @@ class FlasherPluginTest extends TestCase
|
||||
{
|
||||
$plugin = new FlasherPlugin();
|
||||
$rootScript = array(
|
||||
'cdn' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.1/dist/flasher.min.js',
|
||||
'cdn' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.2/dist/flasher.min.js',
|
||||
'local' => '/vendor/flasher/flasher.min.js',
|
||||
);
|
||||
|
||||
@@ -60,7 +60,7 @@ class FlasherPluginTest extends TestCase
|
||||
{
|
||||
$plugin = new FlasherPlugin();
|
||||
$scripts = array(
|
||||
'cdn' => array('https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.1/dist/flasher.min.js'),
|
||||
'cdn' => array('https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.2/dist/flasher.min.js'),
|
||||
'local' => array('/vendor/flasher/flasher.min.js'),
|
||||
);
|
||||
|
||||
@@ -103,12 +103,12 @@ class FlasherPluginTest extends TestCase
|
||||
$config = array(
|
||||
'default' => 'flasher',
|
||||
'root_script' => array(
|
||||
'cdn' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.1/dist/flasher.min.js',
|
||||
'cdn' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.2/dist/flasher.min.js',
|
||||
'local' => '/vendor/flasher/flasher.min.js',
|
||||
),
|
||||
'scripts' => array(),
|
||||
'styles' => array(
|
||||
'cdn' => array('https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.1/dist/flasher.min.css'),
|
||||
'cdn' => array('https://cdn.jsdelivr.net/npm/@flasher/flasher@1.3.2/dist/flasher.min.css'),
|
||||
'local' => array('/vendor/flasher/flasher.min.css'),
|
||||
),
|
||||
'options' => array(),
|
||||
|
||||
@@ -34,6 +34,8 @@ class HtmlPresenterTest extends TestCase
|
||||
$notification->setType('warning');
|
||||
$envelopes[] = new Envelope($notification);
|
||||
|
||||
$livewireListener = $this->getLivewireListenerScript();
|
||||
|
||||
$response = <<<JAVASCRIPT
|
||||
<script type="text/javascript" class="flasher-js">
|
||||
(function() {
|
||||
@@ -88,6 +90,8 @@ class HtmlPresenterTest extends TestCase
|
||||
document.addEventListener('flasher:render', function (event) {
|
||||
render(event.detail);
|
||||
});
|
||||
|
||||
{$livewireListener}
|
||||
}
|
||||
|
||||
if (window.hasOwnProperty('flasher') || !rootScript || document.querySelector('script[src="' + rootScript + '"]')) {
|
||||
@@ -136,4 +140,25 @@ JAVASCRIPT;
|
||||
|
||||
$this->assertEquals($response, $presenter->render(new Response($envelopes, array('envelopes_only' => true))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the script for Livewire event handling.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getLivewireListenerScript()
|
||||
{
|
||||
if (!class_exists('Livewire\LivewireManager')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return <<<JAVASCRIPT
|
||||
document.addEventListener('livewire:navigating', function () {
|
||||
var elements = document.querySelectorAll('.fl-no-cache');
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
elements[i].remove();
|
||||
}
|
||||
});
|
||||
JAVASCRIPT;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ class ResponseManagerTest extends TestCase
|
||||
$storageManager->add($envelopes);
|
||||
|
||||
$responseManager = new ResponseManager(null, $storageManager);
|
||||
$livewireListener = $this->getLivewireListenerScript();
|
||||
|
||||
$response = <<<JAVASCRIPT
|
||||
<script type="text/javascript" class="flasher-js">
|
||||
@@ -101,6 +102,8 @@ class ResponseManagerTest extends TestCase
|
||||
document.addEventListener('flasher:render', function (event) {
|
||||
render(event.detail);
|
||||
});
|
||||
|
||||
{$livewireListener}
|
||||
}
|
||||
|
||||
if (window.hasOwnProperty('flasher') || !rootScript || document.querySelector('script[src="' + rootScript + '"]')) {
|
||||
@@ -132,4 +135,25 @@ JAVASCRIPT;
|
||||
$responseManager = new ResponseManager();
|
||||
$responseManager->render(array(), 'xml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the script for Livewire event handling.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getLivewireListenerScript()
|
||||
{
|
||||
if (!class_exists('Livewire\LivewireManager')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return <<<JAVASCRIPT
|
||||
document.addEventListener('livewire:navigating', function () {
|
||||
var elements = document.querySelectorAll('.fl-no-cache');
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
elements[i].remove();
|
||||
}
|
||||
});
|
||||
JAVASCRIPT;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user