@@ -1505,36 +1505,47 @@ ExecutionVisualizer.prototype.renderDataStructures = function() {
15051505 . selectAll ( 'td' )
15061506 . data ( function ( d , i ) { return d ; } ) /* map varname down both columns */
15071507 . each ( function ( varname , i ) {
1508- console . log ( 'EACH!' , i , varname ) ;
1509-
15101508 if ( i == 1 ) {
15111509 var val = curEntry . globals [ varname ] ;
15121510
1513- if ( isPrimitiveType ( val ) ) {
1514- $ ( this ) . empty ( ) ; // crude but effective; maybe soften with a transition later
1515- renderPrimitiveObject ( val , $ ( this ) ) ;
1516- }
1517- else {
1518- $ ( this ) . empty ( ) ; // crude but effective; maybe soften with a transition later
1511+ // include type in repr to prevent conflating integer 5 with string "5"
1512+ var valStringRepr = String ( typeof val ) + ':' + String ( val ) ;
15191513
1520- // or even better, simply keep <div id=varDivID> around if it already exists
1521- // so that jsPlumb connectors can persist.
1514+ // SUPER HACK - retrieve previous value as a hidden attribute
1515+ var prevValStringRepr = $ ( this ) . attr ( 'data-curvalue' ) ;
15221516
1517+ // IMPORTANT! only clear the div and render a new element if the
1518+ // value has changed
1519+ if ( valStringRepr != prevValStringRepr ) {
1520+ // TODO: render a transition
15231521
1524- // add a stub so that we can connect it with a connector later.
1525- // IE needs this div to be NON-EMPTY in order to properly
1526- // render jsPlumb endpoints, so that's why we add an " "!
1522+ $ ( this ) . empty ( ) ; // crude but effective for now
15271523
1528- // make sure varname doesn't contain any weird
1529- // characters that are illegal for CSS ID's ...
1530- var varDivID = myViz . generateID ( 'global__' + varnameToCssID ( varname ) ) ;
1531- $ ( this ) . append ( '<div id="' + varDivID + '"> </div>' ) ;
1524+ if ( isPrimitiveType ( val ) ) {
1525+ renderPrimitiveObject ( val , $ ( this ) ) ;
1526+ }
1527+ else {
1528+ // add a stub so that we can connect it with a connector later.
1529+ // IE needs this div to be NON-EMPTY in order to properly
1530+ // render jsPlumb endpoints, so that's why we add an " "!
1531+
1532+ // make sure varname doesn't contain any weird
1533+ // characters that are illegal for CSS ID's ...
1534+ var varDivID = myViz . generateID ( 'global__' + varnameToCssID ( varname ) ) ;
1535+ $ ( this ) . append ( '<div id="' + varDivID + '"> </div>' ) ;
1536+
1537+ assert ( ! connectionEndpointIDs . has ( varDivID ) ) ;
1538+ var heapObjID = myViz . generateID ( 'heap_object_' + getRefID ( val ) ) ;
1539+ connectionEndpointIDs . set ( varDivID , heapObjID ) ;
1540+ }
15321541
1533- assert ( ! connectionEndpointIDs . has ( varDivID ) ) ;
1534- var heapObjID = myViz . generateID ( 'heap_object_' + getRefID ( val ) ) ;
1535- connectionEndpointIDs . set ( varDivID , heapObjID ) ;
1542+ console . log ( 'CHANGED' , varname , prevValStringRepr , valStringRepr ) ;
15361543 }
1544+
1545+ // SUPER HACK - set current value as a hidden string attribute
1546+ $ ( this ) . attr ( 'data-curvalue' , valStringRepr ) ;
15371547 }
1548+
15381549 } ) ;
15391550
15401551 globalsD3 . exit ( )
0 commit comments