Browse Source

Treat nil as false in trapGuard:contents:

Herbert Vojčík 11 years ago
parent
commit
97d74f2da4
2 changed files with 17 additions and 8 deletions
  1. 13 6
      lib/js/Trapped-Frontend.js
  2. 4 2
      lib/st/Trapped-Frontend.st

+ 13 - 6
lib/js/Trapped-Frontend.js

@@ -861,17 +861,24 @@ return smalltalk.withContext(function($ctx2) {
 shown=nil;
 shown;
 return self._trap_read_(anArray,(function(gdata){
+var sanitized;
 return smalltalk.withContext(function($ctx3) {
-$1=_st(shown).__eq(gdata);
+if(($receiver = gdata) == nil || $receiver == null){
+sanitized=false;
+} else {
+sanitized=gdata;
+};
+sanitized;
+$1=_st(shown).__eq(sanitized);
 if(! smalltalk.assert($1)){
-shown=gdata;
+shown=sanitized;
 shown;
 $2=shown;
 if(smalltalk.assert($2)){
 _st(snap)._do_((function(){
 return smalltalk.withContext(function($ctx4) {
 return self._contents_(aBlock);
-}, function($ctx4) {$ctx4.fillBlock({},$ctx3,5)})}));
+}, function($ctx4) {$ctx4.fillBlock({},$ctx3,6)})}));
 $3=self._asJQuery();
 $ctx3.sendIdx["asJQuery"]=1;
 return _st($3)._show();
@@ -882,12 +889,12 @@ $5=_st($4)._empty();
 return $5;
 };
 };
-}, function($ctx3) {$ctx3.fillBlock({gdata:gdata},$ctx2,2)})}));
+}, function($ctx3) {$ctx3.fillBlock({gdata:gdata,sanitized:sanitized},$ctx2,2)})}));
 }, function($ctx2) {$ctx2.fillBlock({snap:snap,shown:shown},$ctx1,1)})}));
 return self}, function($ctx1) {$ctx1.fill(self,"trapGuard:contents:",{anArray:anArray,aBlock:aBlock},smalltalk.TagBrush)})},
 args: ["anArray", "aBlock"],
-source: "trapGuard: anArray contents: aBlock\x0a\x09#() trapDescend: [ :snap |\x0a\x09    | shown |\x0a    \x09shown := nil.\x0a\x09    self trap: anArray read: [ :gdata |\x0a    \x09    shown = gdata ifFalse: [\x0a        \x09    shown := gdata.\x0a            \x09shown\x0a\x09\x09\x09\x09\x09ifTrue: [ snap do: [ self contents: aBlock ]. self asJQuery show ]\x0a\x09\x09\x09\x09\x09ifFalse: [ self asJQuery hide; empty ] ] ] ]",
-messageSends: ["trapDescend:", "trap:read:", "ifFalse:", "=", "ifTrue:ifFalse:", "do:", "contents:", "show", "asJQuery", "hide", "empty"],
+source: "trapGuard: anArray contents: aBlock\x0a\x09#() trapDescend: [ :snap |\x0a\x09    | shown |\x0a    \x09shown := nil.\x0a\x09    self trap: anArray read: [ :gdata |\x0a\x09\x09\x09| sanitized |\x0a\x09\x09\x09sanitized := gdata ifNil: [ false ].\x0a    \x09    shown = sanitized ifFalse: [\x0a        \x09    shown := sanitized.\x0a            \x09shown\x0a\x09\x09\x09\x09\x09ifTrue: [ snap do: [ self contents: aBlock ]. self asJQuery show ]\x0a\x09\x09\x09\x09\x09ifFalse: [ self asJQuery hide; empty ] ] ] ]",
+messageSends: ["trapDescend:", "trap:read:", "ifNil:", "ifFalse:", "=", "ifTrue:ifFalse:", "do:", "contents:", "show", "asJQuery", "hide", "empty"],
 referencedClasses: []
 }),
 smalltalk.TagBrush);

+ 4 - 2
lib/st/Trapped-Frontend.st

@@ -293,8 +293,10 @@ trapGuard: anArray contents: aBlock
 	    | shown |
     	shown := nil.
 	    self trap: anArray read: [ :gdata |
-    	    shown = gdata ifFalse: [
-        	    shown := gdata.
+			| sanitized |
+			sanitized := gdata ifNil: [ false ].
+    	    shown = sanitized ifFalse: [
+        	    shown := sanitized.
             	shown
 					ifTrue: [ snap do: [ self contents: aBlock ]. self asJQuery show ]
 					ifFalse: [ self asJQuery hide; empty ] ] ] ]