Browse Source

Use ifEmpty:ifNotEmpty: family.

Herbert Vojčík 7 years ago
parent
commit
4c1ea0e08e
2 changed files with 8 additions and 8 deletions
  1. 7 7
      src/Web.js
  2. 1 1
      src/Web.st

+ 7 - 7
src/Web.js

@@ -2079,7 +2079,7 @@ var clone,caret;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2;
+var $1;
 clone=$recv($recv(anElement)._asJQuery())._clone();
 $1=$recv($globals.TagBrush)._fromJQuery_canvas_(clone,self);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -2087,11 +2087,11 @@ $ctx1.sendIdx["fromJQuery:canvas:"]=1;
 //>>excludeEnd("ctx");
 self._with_($1);
 caret=$recv(clone)._find_("[data-snippet=\x22*\x22]");
-$2=$recv($recv(caret)._toArray())._isEmpty();
-if($core.assert($2)){
+$recv($recv(caret)._toArray())._ifEmpty_((function(){
 caret=clone;
-caret;
-};
+return caret;
+
+}));
 return $recv($globals.TagBrush)._fromJQuery_canvas_($recv(caret)._removeAttr_("data-snippet"),self);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"snippet:",{anElement:anElement,clone:clone,caret:caret},$globals.HTMLCanvas)});
@@ -2099,10 +2099,10 @@ return $recv($globals.TagBrush)._fromJQuery_canvas_($recv(caret)._removeAttr_("d
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: ["anElement"],
-source: "snippet: anElement\x0a\x09\x22Adds clone of anElement, finds [data-snippet=\x22\x22*\x22\x22] subelement\x0a\x09and returns TagBrush as if that subelement was just added.\x0a\x09\x0a\x09Rarely needed to use directly, use `html foo` dynamically installed method\x0a\x09for a snippet named foo.\x22\x0a\x09\x0a\x09| clone caret |\x0a\x09\x0a\x09clone := anElement asJQuery clone.\x0a\x09self with: (TagBrush fromJQuery: clone canvas: self).\x0a\x09caret := clone find: '[data-snippet=\x22*\x22]'.\x0a\x09caret toArray isEmpty ifTrue: [ caret := clone ].\x0a\x09^ TagBrush fromJQuery: (caret removeAttr: 'data-snippet') canvas: self",
+source: "snippet: anElement\x0a\x09\x22Adds clone of anElement, finds [data-snippet=\x22\x22*\x22\x22] subelement\x0a\x09and returns TagBrush as if that subelement was just added.\x0a\x09\x0a\x09Rarely needed to use directly, use `html foo` dynamically installed method\x0a\x09for a snippet named foo.\x22\x0a\x09\x0a\x09| clone caret |\x0a\x09\x0a\x09clone := anElement asJQuery clone.\x0a\x09self with: (TagBrush fromJQuery: clone canvas: self).\x0a\x09caret := clone find: '[data-snippet=\x22*\x22]'.\x0a\x09caret toArray ifEmpty: [ caret := clone ].\x0a\x09^ TagBrush fromJQuery: (caret removeAttr: 'data-snippet') canvas: self",
 referencedClasses: ["TagBrush"],
 //>>excludeEnd("ide");
-messageSends: ["clone", "asJQuery", "with:", "fromJQuery:canvas:", "find:", "ifTrue:", "isEmpty", "toArray", "removeAttr:"]
+messageSends: ["clone", "asJQuery", "with:", "fromJQuery:canvas:", "find:", "ifEmpty:", "toArray", "removeAttr:"]
 }),
 $globals.HTMLCanvas);
 

+ 1 - 1
src/Web.st

@@ -42,7 +42,7 @@ snippet: anElement
 	clone := anElement asJQuery clone.
 	self with: (TagBrush fromJQuery: clone canvas: self).
 	caret := clone find: '[data-snippet="*"]'.
-	caret toArray isEmpty ifTrue: [ caret := clone ].
+	caret toArray ifEmpty: [ caret := clone ].
 	^ TagBrush fromJQuery: (caret removeAttr: 'data-snippet') canvas: self
 ! !