Do not render script methods when no script present, adcd0eb9 followup

This commit is contained in:
Stephen Abello
2023-04-18 14:57:06 +02:00
parent 51617113eb
commit 41b4ef357f

View File

@@ -2,6 +2,7 @@
{# @license http://opensource.org/licenses/AGPL-3.0 #} {# @license http://opensource.org/licenses/AGPL-3.0 #}
{% apply spaceless %} {% apply spaceless %}
{% set sId = oLayout.GetId() | sanitize(constant('utils::ENUM_SANITIZATION_FILTER_VARIABLE_NAME')) %} {% set sId = oLayout.GetId() | sanitize(constant('utils::ENUM_SANITIZATION_FILTER_VARIABLE_NAME')) %}
{% set bHasOnInitOrOnDomReadyScripts = aPage.aJsInlineOnInit is not empty or aPage.aJsInlineOnDomReady is not empty %}
{% if bEscapeContent %} {% if bEscapeContent %}
{{ render_block(oLayout, {aPage: aPage})|escape }} {{ render_block(oLayout, {aPage: aPage})|escape }}
{% else %} {% else %}
@@ -25,19 +26,21 @@
</script> </script>
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}
<script type="text/javascript">
let fOnJsFilesLoaded{{ sId }} = function (fResolve) {
{% for sJsInline in aPage.aJsInlineOnInit %}
{{ sJsInline|raw }}
{% endfor %}
{% for sJsInline in aPage.aJsInlineOnDomReady %} {% if bHasOnInitOrOnDomReadyScripts %}
{{ sJsInline|raw }} <script type="text/javascript">
{% endfor %} let fOnJsFilesLoaded{{ sId }} = function (fResolve) {
fResolve(); {% for sJsInline in aPage.aJsInlineOnInit %}
} {{ sJsInline|raw }}
</script> {% endfor %}
{% for sJsInline in aPage.aJsInlineOnDomReady %}
{{ sJsInline|raw }}
{% endfor %}
fResolve();
}
</script>
{% endif %}
{% set sPromiseId = aPage.sPromiseId %} {% set sPromiseId = aPage.sPromiseId %}
{% if aPage.aJsFiles is not empty %} {% if aPage.aJsFiles is not empty %}
@@ -132,13 +135,15 @@
</script> </script>
{% endblock %} {% endblock %}
{% else %} {% else %}
{% block iboPageJsInlineOnDomReady %} {% if bHasOnInitOrOnDomReadyScripts %}
<script type="text/javascript"> {% block iboPageJsInlineOnDomReady %}
window['{{ sPromiseId }}'] = new Promise(function (fNoJsFileResolve, fNoJsFileReject) { <script type="text/javascript">
fOnJsFilesLoaded{{ sId }}(fNoJsFileResolve); window['{{ sPromiseId }}'] = new Promise(function (fNoJsFileResolve, fNoJsFileReject) {
}); fOnJsFilesLoaded{{ sId }}(fNoJsFileResolve);
</script> });
{% endblock %} </script>
{% endblock %}
{% endif %}
{% endif %} {% endif %}
{% if aDeferredBlocks is not empty %} {% if aDeferredBlocks is not empty %}