Skip to content

Commit f9cd843

Browse files
pankgeorgt-bltg
andauthored
fix: prevent namespace pollution bug (master) (#5171)
* fix: prevent namespace pollution bug * chore: zenodo entry * chore: IIFE to avoid polluting ijulia's js namespace * chore: fix the id again * Update plotly.jl --------- Co-authored-by: t-bltg <[email protected]>
1 parent f4a7e30 commit f9cd843

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.zenodo.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,11 @@
791791
"name": "James Wrigley",
792792
"orcid": "0009-0003-6525-7413",
793793
"type": "Other"
794+
},
795+
{
796+
"affiliation": "@JuliaComputing",
797+
"name": "Παναγιώτης Γεωργακόπουλος",
798+
"type": "Other"
794799
}
795800
],
796801
"upload_type": "software"

src/backends/plotly.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,17 +1108,24 @@ function plotly_html_body(plt, style = nothing)
11081108
requirejs_suffix = "});"
11091109
end
11101110

1111-
unique_tag = replace(string(UUIDs.uuid4()), '-' => '_')
1111+
unique_tag = "id_$(replace(string(UUIDs.uuid4()), '-' => '_'))"
1112+
11121113
html = """
11131114
<div id=\"$unique_tag\" style=\"$style\"></div>
11141115
<script>
1116+
;(()=> {
11151117
function plots_jl_plotly_$unique_tag() {
11161118
$(requirejs_prefix)
11171119
$(js_body(plt, unique_tag))
11181120
$(requirejs_suffix)
11191121
}
1122+
let plotlyloader = window.document.createElement("script")
1123+
let src="https://requirejs.org/docs/release/$(Plots._requirejs_version)/minified/require.js"
1124+
plotlyloader.addEventListener("load", plots_jl_plotly_$unique_tag);
1125+
plotlyloader.src = src
1126+
document.querySelector("#$unique_tag").appendChild(plotlyloader)
1127+
})()
11201128
</script>
1121-
<script src="https://requirejs.org/docs/release/$_requirejs_version/minified/require.js" onload="plots_jl_plotly_$unique_tag()"></script>
11221129
"""
11231130
return html
11241131
end

0 commit comments

Comments
 (0)