Browse Source

Merge pull request #744 from herby/tagbrush-accessors

TagBrush atrribute getters (since it has setter and deleter)
Nicolas Petton 10 years ago
parent
commit
cfd55f38bf
2 changed files with 46 additions and 0 deletions
  1. 38 0
      js/Canvas.js
  2. 8 0
      st/Canvas.st

+ 38 - 0
js/Canvas.js

@@ -2759,6 +2759,44 @@ referencedClasses: []
 }),
 smalltalk.TagBrush);
 
+smalltalk.addMethod(
+smalltalk.method({
+selector: "at:",
+category: 'attributes',
+fn: function (aString){
+var self=this;
+function $Collection(){return smalltalk.Collection||(typeof Collection=="undefined"?nil:Collection)}
+return smalltalk.withContext(function($ctx1) { 
+var $1;
+$1=self._at_ifAbsent_(aString,(function(){
+return smalltalk.withContext(function($ctx2) {
+return _st(_st($Collection())._new())._errorNotFound();
+}, function($ctx2) {$ctx2.fillBlock({},$ctx1,1)})}));
+return $1;
+}, function($ctx1) {$ctx1.fill(self,"at:",{aString:aString},smalltalk.TagBrush)})},
+args: ["aString"],
+source: "at: aString\x0a\x09^ self at: aString ifAbsent: [ Collection new errorNotFound ]",
+messageSends: ["at:ifAbsent:", "errorNotFound", "new"],
+referencedClasses: ["Collection"]
+}),
+smalltalk.TagBrush);
+
+smalltalk.addMethod(
+smalltalk.method({
+selector: "at:ifAbsent:",
+category: 'attributes',
+fn: function (aString,aBlock){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+return self['@element'].hasAttribute(aString) ? self['@element'].getAttribute(aString) : aBlock._value();
+return self}, function($ctx1) {$ctx1.fill(self,"at:ifAbsent:",{aString:aString,aBlock:aBlock},smalltalk.TagBrush)})},
+args: ["aString", "aBlock"],
+source: "at: aString ifAbsent: aBlock\x0a\x09<return self['@element'].hasAttribute(aString) ? self['@element'].getAttribute(aString) : aBlock._value()>",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.TagBrush);
+
 smalltalk.addMethod(
 smalltalk.method({
 selector: "at:put:",

+ 8 - 0
st/Canvas.st

@@ -820,6 +820,14 @@ alt: aString
 	self at: 'alt' put: aString
 !
 
+at: aString
+	^ self at: aString ifAbsent: [ Collection new errorNotFound ]
+!
+
+at: aString ifAbsent: aBlock
+	<return self['@element'].hasAttribute(aString) ? self['@element'].getAttribute(aString) : aBlock._value()>
+!
+
 at: aString put: aValue
 	<self['@element'].setAttribute(aString, aValue)>
 !