Skip to content

Commit 6be0b42

Browse files
committed
Move global inline scripts into app's inline scripts
1 parent d26fcef commit 6be0b42

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

dash/dash.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ def _generate_scripts_html(self):
714714
)
715715
)
716716

717-
global_inline_scripts = list(_callback.GLOBAL_INLINE_SCRIPTS)
717+
self._inline_scripts.extend(_callback.GLOBAL_INLINE_SCRIPTS)
718718
_callback.GLOBAL_INLINE_SCRIPTS.clear()
719719

720720
return "\n".join(
@@ -724,10 +724,7 @@ def _generate_scripts_html(self):
724724
else '<script src="{}"></script>'.format(src)
725725
for src in srcs
726726
]
727-
+ [
728-
"<script>{}</script>".format(src)
729-
for src in (self._inline_scripts + global_inline_scripts)
730-
]
727+
+ ["<script>{}</script>".format(src) for src in self._inline_scripts]
731728
)
732729

733730
def _generate_config_html(self):
@@ -1438,16 +1435,17 @@ def csp_hashes(self, hash_algorithm="sha256"):
14381435

14391436
method = getattr(hashlib, hash_algorithm)
14401437

1438+
self._inline_scripts.extend(_callback.GLOBAL_INLINE_SCRIPTS)
1439+
_callback.GLOBAL_INLINE_SCRIPTS.clear()
1440+
14411441
return [
14421442
"'{hash_algorithm}-{base64_hash}'".format(
14431443
hash_algorithm=hash_algorithm,
14441444
base64_hash=base64.b64encode(
14451445
method(script.encode("utf-8")).digest()
14461446
).decode("utf-8"),
14471447
)
1448-
for script in (
1449-
self._inline_scripts + [self.renderer] + _callback.GLOBAL_INLINE_SCRIPTS
1450-
)
1448+
for script in (self._inline_scripts + [self.renderer])
14511449
]
14521450

14531451
def get_asset_url(self, path):

0 commit comments

Comments
 (0)