@@ -399,6 +399,20 @@ function renderDataStructuresVersion1(curEntry, vizDiv) {
399399}
400400
401401
402+ // make sure varname doesn't contain any weird
403+ // characters that are illegal for CSS ID's ...
404+ //
405+ // I know for a fact that iterator tmp variables named '_[1]'
406+ // are NOT legal names for CSS ID's.
407+ // I also threw in '{', '}', '(', ')', '<', '>' as illegal characters.
408+ //
409+ // TODO: what other characters are illegal???
410+ var lbRE = new RegExp ( '\\[|{|\\(|<' , 'g' ) ;
411+ var rbRE = new RegExp ( '\\]|}|\\)|>' , 'g' ) ;
412+ function varnameToCssID ( varname ) {
413+ return varname . replace ( lbRE , 'LeftB_' ) . replace ( rbRE , '_RightB' ) ;
414+ }
415+
402416// The "2.0" version of renderDataStructures, which renders variables in
403417// a stack and values in a separate heap, with data structure aliasing
404418// explicitly represented via line connectors (thanks to jsPlumb lib).
@@ -527,9 +541,9 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
527541 // IE needs this div to be NON-EMPTY in order to properly
528542 // render jsPlumb endpoints, so that's why we add an " "!
529543
530- // TODO: make sure varname doesn't contain any weird
544+ // make sure varname doesn't contain any weird
531545 // characters that are illegal for CSS ID's ...
532- var varDivID = 'global__' + varname ;
546+ var varDivID = 'global__' + varnameToCssID ( varname ) ;
533547 curTr . find ( "td.stackFrameValue" ) . append ( '<div id="' + varDivID + '"> </div>' ) ;
534548
535549 assert ( connectionEndpointIDs [ varDivID ] === undefined ) ;
@@ -605,9 +619,9 @@ function renderDataStructuresVersion2(curEntry, vizDiv) {
605619 // IE needs this div to be NON-EMPTY in order to properly
606620 // render jsPlumb endpoints, so that's why we add an " "!
607621
608- // TODO: make sure varname doesn't contain any weird
622+ // make sure varname doesn't contain any weird
609623 // characters that are illegal for CSS ID's ...
610- var varDivID = divID + '__' + varname ;
624+ var varDivID = divID + '__' + varnameToCssID ( varname ) ;
611625 curTr . find ( "td.stackFrameValue" ) . append ( '<div id="' + varDivID + '"> </div>' ) ;
612626
613627 assert ( connectionEndpointIDs [ varDivID ] === undefined ) ;
0 commit comments