Skip to content

Commit 8db368c

Browse files
committed
Integrated changes noted in PR #215 comments
1 parent 35e7165 commit 8db368c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

text_extensions_for_pandas/resources/span_array.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Increment the version to invalidate the cached script
22
const VERSION = 0.75
3+
const global_stylesheet = document.head.querySelector("style.span-array-css")
4+
const local_stylesheet = document.currentScript.parentElement.querySelector("style.span-array-css")
35

46
if(window.SpanArray == undefined || window.SpanArray.VERSION == undefined || window.SpanArray.VERSION < VERSION) {
57

68
// Replace global SpanArray CSS with latest copy
7-
const global_stylesheet = document.head.querySelector("style.span-array-css")
8-
const local_stylesheet = document.currentScript.parentElement.querySelector("style.span-array-css")
99
if(local_stylesheet != undefined) {
1010
if(global_stylesheet != undefined) {
1111
document.head.removeChild(global_stylesheet)
@@ -385,17 +385,18 @@ if(window.SpanArray == undefined || window.SpanArray.VERSION == undefined || win
385385
if(closest_tr == undefined) return
386386

387387
const matching_span = doc_object.lookup_table[closest_tr.getAttribute("data-id")]
388+
if(matching_span == undefined) return
388389

389390
switch(closest_control_button.getAttribute("data-control")) {
390391
case "visibility":
391392
{
392-
if(matching_span != undefined) matching_span.visible = !matching_span.visible
393+
matching_span.visible = !matching_span.visible
393394
source_spanarray.render()
394395
}
395396
break;
396397
case "highlight":
397398
{
398-
if(matching_span != undefined) matching_span.highlighted = !matching_span.highlighted
399+
matching_span.highlighted = !matching_span.highlighted
399400
source_spanarray.render()
400401
}
401402
break;
@@ -437,9 +438,7 @@ if(window.SpanArray == undefined || window.SpanArray.VERSION == undefined || win
437438
} else {
438439
// SpanArray JS is already defined and not an outdated copy
439440
// Replace global SpanArray CSS with latest copy IFF global stylesheet is undefined
440-
441-
const global_stylesheet = document.head.querySelector("style.span-array-css")
442-
const local_stylesheet = document.currentScript.parentElement.querySelector("style.span-array-css")
441+
443442
if(local_stylesheet != undefined) {
444443
if(global_stylesheet == undefined) {
445444
document.head.appendChild(local_stylesheet)

0 commit comments

Comments
 (0)