Browse Source

move to streaming API

Changed tests, make them green.
Herbert Vojčík 9 years ago
parent
commit
255ba52f28
5 changed files with 326 additions and 294 deletions
  1. 1 1
      bower.json
  2. 122 150
      src/DOMite-Tests.js
  3. 28 28
      src/DOMite-Tests.st
  4. 147 99
      src/DOMite.js
  5. 28 16
      src/DOMite.st

+ 1 - 1
bower.json

@@ -27,7 +27,7 @@
     ],
     "private": false,
     "dependencies": {
-        "amber": "^0.14.10"
+        "amber": ">=0.14.11"
     },
     "devDependencies": {
         "amber-ide-starter-dialog": "^0.1.0",

+ 122 - 150
src/DOMite-Tests.js

@@ -75,7 +75,7 @@ function $Domite(){return $globals.Domite||(typeof Domite=="undefined"?nil:Domit
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $3,$2,$1,$4;
-$recv($recv($Domite())._new())._insertDomite_($recv($Domite())._newElement_("p"));
+$recv($recv($Domite())._new()).__lt_lt($recv($Domite())._newElement_("p"));
 $3=$recv(document)._body();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["body"]=1;
@@ -95,10 +95,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testDefaultInsertElement\x0a\x09Domite new insertDomite: (Domite newElement: 'p').\x0a\x09self assert: (document body innerHTML endsWith: '<p></p>').\x0a\x09document body removeChild: document body lastChild",
+source: "testDefaultInsertElement\x0a\x09Domite new << (Domite newElement: 'p').\x0a\x09self assert: (document body innerHTML endsWith: '<p></p>').\x0a\x09document body removeChild: document body lastChild",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["insertDomite:", "new", "newElement:", "assert:", "endsWith:", "innerHTML", "body", "removeChild:", "lastChild"]
+messageSends: ["<<", "new", "newElement:", "assert:", "endsWith:", "innerHTML", "body", "removeChild:", "lastChild"]
 }),
 $globals.DOMiteTest);
 
@@ -113,7 +113,7 @@ function $Domite(){return $globals.Domite||(typeof Domite=="undefined"?nil:Domit
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 var $3,$2,$1,$4;
-$recv($recv($Domite())._new())._insertString_("a foo in a bar");
+$recv($recv($Domite())._new()).__lt_lt("a foo in a bar");
 $3=$recv(document)._body();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["body"]=1;
@@ -133,10 +133,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testDefaultInsertString\x0a\x09Domite new insertString: 'a foo in a bar'.\x0a\x09self assert: (document body innerHTML endsWith: 'a foo in a bar').\x0a\x09document body removeChild: document body lastChild",
+source: "testDefaultInsertString\x0a\x09Domite new << 'a foo in a bar'.\x0a\x09self assert: (document body innerHTML endsWith: 'a foo in a bar').\x0a\x09document body removeChild: document body lastChild",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["insertString:", "new", "assert:", "endsWith:", "innerHTML", "body", "removeChild:", "lastChild"]
+messageSends: ["<<", "new", "assert:", "endsWith:", "innerHTML", "body", "removeChild:", "lastChild"]
 }),
 $globals.DOMiteTest);
 
@@ -150,23 +150,23 @@ function $Domite(){return $globals.Domite||(typeof Domite=="undefined"?nil:Domit
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2,$5,$4,$3,$6;
-$1=$recv($Domite())._open();
-$recv($1)._insertString_("a foo in a bar");
-$2=$recv($1)._yourself();
-$recv($recv($Domite())._new())._insertDomite_($2);
-$5=$recv(document)._body();
+var $3,$2,$1,$4;
+$recv($recv($Domite())._new()).__lt_lt($recv($recv($Domite())._newStream()).__lt_lt("a foo in a bar"));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["<<"]=1;
+//>>excludeEnd("ctx");
+$3=$recv(document)._body();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["body"]=1;
 //>>excludeEnd("ctx");
-$4=$recv($5)._innerHTML();
-$3=$recv($4)._endsWith_("a foo in a bar");
-self._assert_($3);
-$6=$recv(document)._body();
+$2=$recv($3)._innerHTML();
+$1=$recv($2)._endsWith_("a foo in a bar");
+self._assert_($1);
+$4=$recv(document)._body();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["body"]=2;
 //>>excludeEnd("ctx");
-$recv($6)._removeChild_($recv($recv(document)._body())._lastChild());
+$recv($4)._removeChild_($recv($recv(document)._body())._lastChild());
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 }, function($ctx1) {$ctx1.fill(self,"testDefaultInsertStringInFragment",{},$globals.DOMiteTest)});
@@ -174,10 +174,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testDefaultInsertStringInFragment\x0a\x09Domite new insertDomite: (Domite open insertString: 'a foo in a bar'; yourself).\x0a\x09self assert: (document body innerHTML endsWith: 'a foo in a bar').\x0a\x09document body removeChild: document body lastChild",
+source: "testDefaultInsertStringInFragment\x0a\x09Domite new << (Domite newStream << 'a foo in a bar').\x0a\x09self assert: (document body innerHTML endsWith: 'a foo in a bar').\x0a\x09document body removeChild: document body lastChild",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["insertDomite:", "new", "insertString:", "open", "yourself", "assert:", "endsWith:", "innerHTML", "body", "removeChild:", "lastChild"]
+messageSends: ["<<", "new", "newStream", "assert:", "endsWith:", "innerHTML", "body", "removeChild:", "lastChild"]
 }),
 $globals.DOMiteTest);
 
@@ -242,7 +242,7 @@ function $Domite(){return $globals.Domite||(typeof Domite=="undefined"?nil:Domit
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 d=$recv($Domite())._fromSelector_("html body div#fixture");
-$recv(d)._insertDomite_($recv($Domite())._newElement_("p"));
+$recv(d).__lt_lt($recv($Domite())._newElement_("p"));
 self._assert_($recv($recv($recv(document)._body())._innerHTML())._endsWith_(">sentinel<p></p></div>"));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -251,10 +251,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testInsertElement\x0a\x09| d |\x0a\x09d := Domite fromSelector: 'html body div#fixture'.\x0a\x09d insertDomite: (Domite newElement: 'p').\x0a\x09self assert: (document body innerHTML endsWith: '>sentinel<p></p></div>')",
+source: "testInsertElement\x0a\x09| d |\x0a\x09d := Domite fromSelector: 'html body div#fixture'.\x0a\x09d << (Domite newElement: 'p').\x0a\x09self assert: (document body innerHTML endsWith: '>sentinel<p></p></div>')",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["fromSelector:", "insertDomite:", "newElement:", "assert:", "endsWith:", "innerHTML", "body"]
+messageSends: ["fromSelector:", "<<", "newElement:", "assert:", "endsWith:", "innerHTML", "body"]
 }),
 $globals.DOMiteTest);
 
@@ -274,13 +274,16 @@ p=$recv($Domite())._newElement_("p");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["newElement:"]=1;
 //>>excludeEnd("ctx");
-$recv(d)._insertDomite_(p);
+$recv(d).__lt_lt(p);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=1;
+$ctx1.sendIdx["<<"]=1;
 //>>excludeEnd("ctx");
 s=$recv($Domite())._newElement_("span");
-$recv(p)._insertDomite_(s);
-$recv(s)._insertString_("dom-mite");
+$recv(p).__lt_lt(s);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["<<"]=2;
+//>>excludeEnd("ctx");
+$recv(s).__lt_lt("dom-mite");
 self._assert_($recv($recv($recv(document)._body())._innerHTML())._endsWith_(">sentinel<p><span>dom-mite</span></p></div>"));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -289,10 +292,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testInsertElementTwoLevel\x0a\x09| d p s |\x0a\x09d := Domite fromElement: fixtureDiv.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d insertDomite: p.\x0a\x09s := Domite newElement: 'span'.\x0a\x09p insertDomite: s.\x0a\x09s insertString: 'dom-mite'.\x0a\x09self assert: (document body innerHTML endsWith: '>sentinel<p><span>dom-mite</span></p></div>')",
+source: "testInsertElementTwoLevel\x0a\x09| d p s |\x0a\x09d := Domite fromElement: fixtureDiv.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d << p.\x0a\x09s := Domite newElement: 'span'.\x0a\x09p << s.\x0a\x09s << 'dom-mite'.\x0a\x09self assert: (document body innerHTML endsWith: '>sentinel<p><span>dom-mite</span></p></div>')",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["fromElement:", "newElement:", "insertDomite:", "insertString:", "assert:", "endsWith:", "innerHTML", "body"]
+messageSends: ["fromElement:", "newElement:", "<<", "assert:", "endsWith:", "innerHTML", "body"]
 }),
 $globals.DOMiteTest);
 
@@ -307,53 +310,43 @@ function $Domite(){return $globals.Domite||(typeof Domite=="undefined"?nil:Domit
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$3,$4,$2,$5,$7,$8,$6,$9,$10;
+var $1,$3,$2,$4,$6,$5;
 d=$recv($Domite())._fromSelector_("#fixture");
 p=$recv($Domite())._newElement_("p");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["newElement:"]=1;
 //>>excludeEnd("ctx");
 $1=d;
-$3=$recv($Domite())._open();
+$3=$recv($Domite())._newStream();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["open"]=1;
+$ctx1.sendIdx["newStream"]=1;
 //>>excludeEnd("ctx");
-$recv($3)._insertDomite_(p);
+$2=$recv($3).__lt_lt(p);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=2;
+$ctx1.sendIdx["<<"]=2;
 //>>excludeEnd("ctx");
-$4=$recv($3)._yourself();
+$recv($1).__lt_lt($2);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["yourself"]=1;
-//>>excludeEnd("ctx");
-$2=$4;
-$recv($1)._insertDomite_($2);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=1;
+$ctx1.sendIdx["<<"]=1;
 //>>excludeEnd("ctx");
 s=$recv($Domite())._newElement_("span");
-$5=p;
-$7=$recv($Domite())._open();
+$4=p;
+$6=$recv($Domite())._newStream();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["open"]=2;
+$ctx1.sendIdx["newStream"]=2;
 //>>excludeEnd("ctx");
-$recv($7)._insertDomite_(s);
+$5=$recv($6).__lt_lt(s);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=4;
+$ctx1.sendIdx["<<"]=4;
 //>>excludeEnd("ctx");
-$8=$recv($7)._yourself();
+$recv($4).__lt_lt($5);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["yourself"]=2;
+$ctx1.sendIdx["<<"]=3;
 //>>excludeEnd("ctx");
-$6=$8;
-$recv($5)._insertDomite_($6);
+$recv(s).__lt_lt($recv($recv($Domite())._newStream()).__lt_lt("dom-mite"));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=3;
+$ctx1.sendIdx["<<"]=5;
 //>>excludeEnd("ctx");
-$9=$recv($Domite())._open();
-$recv($9)._insertString_("dom-mite");
-$10=$recv($9)._yourself();
-$recv(s)._insertDomite_($10);
 self._assert_($recv($recv($recv(document)._body())._innerHTML())._endsWith_(">sentinel<p><span>dom-mite</span></p></div>"));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -362,10 +355,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testInsertElementTwoLevelViaFragments\x0a\x09| d p s |\x0a\x09d := Domite fromSelector: '#fixture'.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d insertDomite: (Domite open insertDomite: p; yourself).\x0a\x09s := Domite newElement: 'span'.\x0a\x09p insertDomite: (Domite open insertDomite: s; yourself).\x0a\x09s insertDomite: (Domite open insertString: 'dom-mite'; yourself).\x0a\x09self assert: (document body innerHTML endsWith: '>sentinel<p><span>dom-mite</span></p></div>')",
+source: "testInsertElementTwoLevelViaFragments\x0a\x09| d p s |\x0a\x09d := Domite fromSelector: '#fixture'.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d << (Domite newStream << p).\x0a\x09s := Domite newElement: 'span'.\x0a\x09p << (Domite newStream << s).\x0a\x09s << (Domite newStream << 'dom-mite').\x0a\x09self assert: (document body innerHTML endsWith: '>sentinel<p><span>dom-mite</span></p></div>')",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["fromSelector:", "newElement:", "insertDomite:", "open", "yourself", "insertString:", "assert:", "endsWith:", "innerHTML", "body"]
+messageSends: ["fromSelector:", "newElement:", "<<", "newStream", "assert:", "endsWith:", "innerHTML", "body"]
 }),
 $globals.DOMiteTest);
 
@@ -380,96 +373,67 @@ function $Domite(){return $globals.Domite||(typeof Domite=="undefined"?nil:Domit
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$3,$4,$6,$7,$5,$8,$2,$9,$11,$12,$14,$15,$13,$16,$10,$17,$19,$20,$22,$23,$21,$24,$18;
+var $1,$3,$5,$4,$2,$6,$8,$10,$9,$7,$11,$13,$12;
 d=$recv($Domite())._fromElement_(self["@fixtureDiv"]);
 p=$recv($Domite())._newElement_("p");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["newElement:"]=1;
 //>>excludeEnd("ctx");
 $1=d;
-$3=$recv($Domite())._open();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["open"]=1;
-//>>excludeEnd("ctx");
-$4=$3;
-$6=$recv($Domite())._open();
+$3=$recv($Domite())._newStream();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["open"]=2;
+$ctx1.sendIdx["newStream"]=1;
 //>>excludeEnd("ctx");
-$recv($6)._insertDomite_(p);
+$5=$recv($Domite())._newStream();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=3;
+$ctx1.sendIdx["newStream"]=2;
 //>>excludeEnd("ctx");
-$7=$recv($6)._yourself();
+$4=$recv($5).__lt_lt(p);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["yourself"]=1;
+$ctx1.sendIdx["<<"]=3;
 //>>excludeEnd("ctx");
-$5=$7;
-$recv($4)._insertDomite_($5);
+$2=$recv($3).__lt_lt($4);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=2;
+$ctx1.sendIdx["<<"]=2;
 //>>excludeEnd("ctx");
-$8=$recv($3)._yourself();
+$recv($1).__lt_lt($2);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["yourself"]=2;
-//>>excludeEnd("ctx");
-$2=$8;
-$recv($1)._insertDomite_($2);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=1;
+$ctx1.sendIdx["<<"]=1;
 //>>excludeEnd("ctx");
 s=$recv($Domite())._newElement_("span");
-$9=p;
-$11=$recv($Domite())._open();
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["open"]=3;
-//>>excludeEnd("ctx");
-$12=$11;
-$14=$recv($Domite())._open();
+$6=p;
+$8=$recv($Domite())._newStream();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["open"]=4;
+$ctx1.sendIdx["newStream"]=3;
 //>>excludeEnd("ctx");
-$recv($14)._insertDomite_(s);
+$10=$recv($Domite())._newStream();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=6;
+$ctx1.sendIdx["newStream"]=4;
 //>>excludeEnd("ctx");
-$15=$recv($14)._yourself();
+$9=$recv($10).__lt_lt(s);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["yourself"]=3;
+$ctx1.sendIdx["<<"]=6;
 //>>excludeEnd("ctx");
-$13=$15;
-$recv($12)._insertDomite_($13);
+$7=$recv($8).__lt_lt($9);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=5;
+$ctx1.sendIdx["<<"]=5;
 //>>excludeEnd("ctx");
-$16=$recv($11)._yourself();
+$recv($6).__lt_lt($7);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["yourself"]=4;
+$ctx1.sendIdx["<<"]=4;
 //>>excludeEnd("ctx");
-$10=$16;
-$recv($9)._insertDomite_($10);
+$11=s;
+$13=$recv($Domite())._newStream();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=4;
+$ctx1.sendIdx["newStream"]=5;
 //>>excludeEnd("ctx");
-$17=s;
-$19=$recv($Domite())._open();
+$12=$recv($13).__lt_lt($recv($recv($Domite())._newStream()).__lt_lt("dom-mite"));
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["open"]=5;
+$ctx1.sendIdx["<<"]=8;
 //>>excludeEnd("ctx");
-$20=$19;
-$22=$recv($Domite())._open();
-$recv($22)._insertString_("dom-mite");
-$23=$recv($22)._yourself();
+$recv($11).__lt_lt($12);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["yourself"]=5;
-//>>excludeEnd("ctx");
-$21=$23;
-$recv($20)._insertDomite_($21);
-$24=$recv($19)._yourself();
-$18=$24;
-$recv($17)._insertDomite_($18);
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=7;
+$ctx1.sendIdx["<<"]=7;
 //>>excludeEnd("ctx");
 self._assert_($recv($recv($recv(document)._body())._innerHTML())._endsWith_(">sentinel<p><span>dom-mite</span></p></div>"));
 return self;
@@ -479,10 +443,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testInsertElementTwoLevelViaTwoLevelFragments\x0a\x09| d p s |\x0a\x09d := Domite fromElement: fixtureDiv.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d insertDomite: (Domite open insertDomite: (Domite open insertDomite: p; yourself); yourself).\x0a\x09s := Domite newElement: 'span'.\x0a\x09p insertDomite: (Domite open insertDomite: (Domite open insertDomite: s; yourself); yourself).\x0a\x09s insertDomite: (Domite open insertDomite: (Domite open insertString: 'dom-mite'; yourself); yourself).\x0a\x09self assert: (document body innerHTML endsWith: '>sentinel<p><span>dom-mite</span></p></div>')",
+source: "testInsertElementTwoLevelViaTwoLevelFragments\x0a\x09| d p s |\x0a\x09d := Domite fromElement: fixtureDiv.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d << (Domite newStream << (Domite newStream << p)).\x0a\x09s := Domite newElement: 'span'.\x0a\x09p << (Domite newStream << (Domite newStream << s)).\x0a\x09s << (Domite newStream << (Domite newStream << 'dom-mite')).\x0a\x09self assert: (document body innerHTML endsWith: '>sentinel<p><span>dom-mite</span></p></div>')",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["fromElement:", "newElement:", "insertDomite:", "open", "yourself", "insertString:", "assert:", "endsWith:", "innerHTML", "body"]
+messageSends: ["fromElement:", "newElement:", "<<", "newStream", "assert:", "endsWith:", "innerHTML", "body"]
 }),
 $globals.DOMiteTest);
 
@@ -498,7 +462,7 @@ function $Domite(){return $globals.Domite||(typeof Domite=="undefined"?nil:Domit
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
 d=$recv($Domite())._fromElement_(self["@fixtureDiv"]);
-$recv(d)._insertString_("a foo in a bar");
+$recv(d).__lt_lt("a foo in a bar");
 self._assert_($recv($recv($recv(document)._body())._innerHTML())._endsWith_(">sentinela foo in a bar</div>"));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -507,10 +471,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testInsertString\x0a\x09| d |\x0a\x09d := Domite fromElement: fixtureDiv.\x0a\x09d insertString: 'a foo in a bar'.\x0a\x09self assert: (document body innerHTML endsWith: '>sentinela foo in a bar</div>')",
+source: "testInsertString\x0a\x09| d |\x0a\x09d := Domite fromElement: fixtureDiv.\x0a\x09d << 'a foo in a bar'.\x0a\x09self assert: (document body innerHTML endsWith: '>sentinela foo in a bar</div>')",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["fromElement:", "insertString:", "assert:", "endsWith:", "innerHTML", "body"]
+messageSends: ["fromElement:", "<<", "assert:", "endsWith:", "innerHTML", "body"]
 }),
 $globals.DOMiteTest);
 
@@ -525,12 +489,11 @@ function $Domite(){return $globals.Domite||(typeof Domite=="undefined"?nil:Domit
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2;
 d=$recv($Domite())._fromSelector_("#fixture");
-$1=$recv($Domite())._open();
-$recv($1)._insertString_("a foo in a bar");
-$2=$recv($1)._yourself();
-$recv(d)._insertDomite_($2);
+$recv(d).__lt_lt($recv($recv($Domite())._newStream()).__lt_lt("a foo in a bar"));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["<<"]=1;
+//>>excludeEnd("ctx");
 self._assert_($recv($recv($recv(document)._body())._innerHTML())._endsWith_(">sentinela foo in a bar</div>"));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -539,10 +502,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testInsertStringInFragment\x0a\x09| d |\x0a\x09d := Domite fromSelector: '#fixture'.\x0a\x09d insertDomite: (Domite open insertString: 'a foo in a bar'; yourself).\x0a\x09self assert: (document body innerHTML endsWith: '>sentinela foo in a bar</div>')",
+source: "testInsertStringInFragment\x0a\x09| d |\x0a\x09d := Domite fromSelector: '#fixture'.\x0a\x09d << (Domite newStream << 'a foo in a bar').\x0a\x09self assert: (document body innerHTML endsWith: '>sentinela foo in a bar</div>')",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["fromSelector:", "insertDomite:", "insertString:", "open", "yourself", "assert:", "endsWith:", "innerHTML", "body"]
+messageSends: ["fromSelector:", "<<", "newStream", "assert:", "endsWith:", "innerHTML", "body"]
 }),
 $globals.DOMiteTest);
 
@@ -562,13 +525,16 @@ p=$recv($Domite())._newElement_("p");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["newElement:"]=1;
 //>>excludeEnd("ctx");
-$recv(d)._insertDomite_(p);
+$recv(d).__lt_lt(p);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=1;
+$ctx1.sendIdx["<<"]=1;
 //>>excludeEnd("ctx");
 s=$recv($Domite())._newElement_("span");
-$recv(d)._insertDomite_(s);
-$recv(d)._insertString_("dom-mite");
+$recv(d).__lt_lt(s);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["<<"]=2;
+//>>excludeEnd("ctx");
+$recv(d).__lt_lt("dom-mite");
 self._assert_($recv($recv($recv(document)._body())._innerHTML())._endsWith_(">sentinel<p></p><span></span>dom-mite</div>"));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -577,10 +543,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testMultipleInserts\x0a\x09| d p s |\x0a\x09d := Domite fromElement: fixtureDiv.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d insertDomite: p.\x0a\x09s := Domite newElement: 'span'.\x0a\x09d insertDomite: s.\x0a\x09d insertString: 'dom-mite'.\x0a\x09self assert: (document body innerHTML endsWith: '>sentinel<p></p><span></span>dom-mite</div>')",
+source: "testMultipleInserts\x0a\x09| d p s |\x0a\x09d := Domite fromElement: fixtureDiv.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d << p.\x0a\x09s := Domite newElement: 'span'.\x0a\x09d << s.\x0a\x09d << 'dom-mite'.\x0a\x09self assert: (document body innerHTML endsWith: '>sentinel<p></p><span></span>dom-mite</div>')",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["fromElement:", "newElement:", "insertDomite:", "insertString:", "assert:", "endsWith:", "innerHTML", "body"]
+messageSends: ["fromElement:", "newElement:", "<<", "assert:", "endsWith:", "innerHTML", "body"]
 }),
 $globals.DOMiteTest);
 
@@ -600,22 +566,25 @@ p=$recv($Domite())._newElement_("p");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["newElement:"]=1;
 //>>excludeEnd("ctx");
-$recv(d)._insertDomite_(p);
+$recv(d).__lt_lt(p);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=1;
+$ctx1.sendIdx["<<"]=1;
 //>>excludeEnd("ctx");
 s=$recv($Domite())._newElement_("span");
-$recv(d)._insertDomite_(s);
-$recv(d)._clearHere();
+$recv(d).__lt_lt(s);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["clearHere"]=1;
+$ctx1.sendIdx["<<"]=2;
 //>>excludeEnd("ctx");
-$recv(d)._insertString_("dom-mite");
-$recv(d)._clearHere();
+$recv(d)._resetContents();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["clearHere"]=2;
+$ctx1.sendIdx["resetContents"]=1;
 //>>excludeEnd("ctx");
-$recv(d)._clearHere();
+$recv(d).__lt_lt("dom-mite");
+$recv(d)._resetContents();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["resetContents"]=2;
+//>>excludeEnd("ctx");
+$recv(d)._resetContents();
 self._assert_($recv($recv($recv(document)._body())._innerHTML())._endsWith_("></div>"));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -624,10 +593,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testMultipleInsertsWithClear\x0a\x09| d p s |\x0a\x09d := Domite fromSelector: '#fixture'.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d insertDomite: p.\x0a\x09s := Domite newElement: 'span'.\x0a\x09d insertDomite: s.\x0a\x09d clearHere.\x0a\x09d insertString: 'dom-mite'.\x0a\x09d clearHere.\x0a\x09d clearHere.\x0a\x09self assert: (document body innerHTML endsWith: '></div>')",
+source: "testMultipleInsertsWithClear\x0a\x09| d p s |\x0a\x09d := Domite fromSelector: '#fixture'.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d << p.\x0a\x09s := Domite newElement: 'span'.\x0a\x09d << s.\x0a\x09d resetContents.\x0a\x09d << 'dom-mite'.\x0a\x09d resetContents.\x0a\x09d resetContents.\x0a\x09self assert: (document body innerHTML endsWith: '></div>')",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["fromSelector:", "newElement:", "insertDomite:", "clearHere", "insertString:", "assert:", "endsWith:", "innerHTML", "body"]
+messageSends: ["fromSelector:", "newElement:", "<<", "resetContents", "assert:", "endsWith:", "innerHTML", "body"]
 }),
 $globals.DOMiteTest);
 
@@ -647,14 +616,17 @@ p=$recv($Domite())._newElement_("p");
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["newElement:"]=1;
 //>>excludeEnd("ctx");
-$recv(d)._insertDomite_(p);
+$recv(d).__lt_lt(p);
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["insertDomite:"]=1;
+$ctx1.sendIdx["<<"]=1;
 //>>excludeEnd("ctx");
 s=$recv($Domite())._newElement_("span");
-$recv(d)._insertDomite_(s);
-$recv(d)._clearHere();
-$recv(d)._insertString_("dom-mite");
+$recv(d).__lt_lt(s);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["<<"]=2;
+//>>excludeEnd("ctx");
+$recv(d)._resetContents();
+$recv(d).__lt_lt("dom-mite");
 self._assert_($recv($recv($recv(document)._body())._innerHTML())._endsWith_(">dom-mite</div>"));
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
@@ -663,10 +635,10 @@ return self;
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "testMultipleInsertsWithClearInBetween\x0a\x09| d p s |\x0a\x09d := Domite fromElement: fixtureDiv.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d insertDomite: p.\x0a\x09s := Domite newElement: 'span'.\x0a\x09d insertDomite: s.\x0a\x09d clearHere.\x0a\x09d insertString: 'dom-mite'.\x0a\x09self assert: (document body innerHTML endsWith: '>dom-mite</div>')",
+source: "testMultipleInsertsWithClearInBetween\x0a\x09| d p s |\x0a\x09d := Domite fromElement: fixtureDiv.\x0a\x09p := Domite newElement: 'p'.\x0a\x09d << p.\x0a\x09s := Domite newElement: 'span'.\x0a\x09d << s.\x0a\x09d resetContents.\x0a\x09d << 'dom-mite'.\x0a\x09self assert: (document body innerHTML endsWith: '>dom-mite</div>')",
 referencedClasses: ["Domite"],
 //>>excludeEnd("ide");
-messageSends: ["fromElement:", "newElement:", "insertDomite:", "clearHere", "insertString:", "assert:", "endsWith:", "innerHTML", "body"]
+messageSends: ["fromElement:", "newElement:", "<<", "resetContents", "assert:", "endsWith:", "innerHTML", "body"]
 }),
 $globals.DOMiteTest);
 

+ 28 - 28
src/DOMite-Tests.st

@@ -22,19 +22,19 @@ tearDown
 !DOMiteTest methodsFor: 'testing'!
 
 testDefaultInsertElement
-	Domite new insertDomite: (Domite newElement: 'p').
+	Domite new << (Domite newElement: 'p').
 	self assert: (document body innerHTML endsWith: '<p></p>').
 	document body removeChild: document body lastChild
 !
 
 testDefaultInsertString
-	Domite new insertString: 'a foo in a bar'.
+	Domite new << 'a foo in a bar'.
 	self assert: (document body innerHTML endsWith: 'a foo in a bar').
 	document body removeChild: document body lastChild
 !
 
 testDefaultInsertStringInFragment
-	Domite new insertDomite: (Domite open insertString: 'a foo in a bar'; yourself).
+	Domite new << (Domite newStream << 'a foo in a bar').
 	self assert: (document body innerHTML endsWith: 'a foo in a bar').
 	document body removeChild: document body lastChild
 !
@@ -52,7 +52,7 @@ testFromBadSelectorIsInvalid
 testInsertElement
 	| d |
 	d := Domite fromSelector: 'html body div#fixture'.
-	d insertDomite: (Domite newElement: 'p').
+	d << (Domite newElement: 'p').
 	self assert: (document body innerHTML endsWith: '>sentinel<p></p></div>')
 !
 
@@ -60,10 +60,10 @@ testInsertElementTwoLevel
 	| d p s |
 	d := Domite fromElement: fixtureDiv.
 	p := Domite newElement: 'p'.
-	d insertDomite: p.
+	d << p.
 	s := Domite newElement: 'span'.
-	p insertDomite: s.
-	s insertString: 'dom-mite'.
+	p << s.
+	s << 'dom-mite'.
 	self assert: (document body innerHTML endsWith: '>sentinel<p><span>dom-mite</span></p></div>')
 !
 
@@ -71,10 +71,10 @@ testInsertElementTwoLevelViaFragments
 	| d p s |
 	d := Domite fromSelector: '#fixture'.
 	p := Domite newElement: 'p'.
-	d insertDomite: (Domite open insertDomite: p; yourself).
+	d << (Domite newStream << p).
 	s := Domite newElement: 'span'.
-	p insertDomite: (Domite open insertDomite: s; yourself).
-	s insertDomite: (Domite open insertString: 'dom-mite'; yourself).
+	p << (Domite newStream << s).
+	s << (Domite newStream << 'dom-mite').
 	self assert: (document body innerHTML endsWith: '>sentinel<p><span>dom-mite</span></p></div>')
 !
 
@@ -82,24 +82,24 @@ testInsertElementTwoLevelViaTwoLevelFragments
 	| d p s |
 	d := Domite fromElement: fixtureDiv.
 	p := Domite newElement: 'p'.
-	d insertDomite: (Domite open insertDomite: (Domite open insertDomite: p; yourself); yourself).
+	d << (Domite newStream << (Domite newStream << p)).
 	s := Domite newElement: 'span'.
-	p insertDomite: (Domite open insertDomite: (Domite open insertDomite: s; yourself); yourself).
-	s insertDomite: (Domite open insertDomite: (Domite open insertString: 'dom-mite'; yourself); yourself).
+	p << (Domite newStream << (Domite newStream << s)).
+	s << (Domite newStream << (Domite newStream << 'dom-mite')).
 	self assert: (document body innerHTML endsWith: '>sentinel<p><span>dom-mite</span></p></div>')
 !
 
 testInsertString
 	| d |
 	d := Domite fromElement: fixtureDiv.
-	d insertString: 'a foo in a bar'.
+	d << 'a foo in a bar'.
 	self assert: (document body innerHTML endsWith: '>sentinela foo in a bar</div>')
 !
 
 testInsertStringInFragment
 	| d |
 	d := Domite fromSelector: '#fixture'.
-	d insertDomite: (Domite open insertString: 'a foo in a bar'; yourself).
+	d << (Domite newStream << 'a foo in a bar').
 	self assert: (document body innerHTML endsWith: '>sentinela foo in a bar</div>')
 !
 
@@ -107,10 +107,10 @@ testMultipleInserts
 	| d p s |
 	d := Domite fromElement: fixtureDiv.
 	p := Domite newElement: 'p'.
-	d insertDomite: p.
+	d << p.
 	s := Domite newElement: 'span'.
-	d insertDomite: s.
-	d insertString: 'dom-mite'.
+	d << s.
+	d << 'dom-mite'.
 	self assert: (document body innerHTML endsWith: '>sentinel<p></p><span></span>dom-mite</div>')
 !
 
@@ -118,13 +118,13 @@ testMultipleInsertsWithClear
 	| d p s |
 	d := Domite fromSelector: '#fixture'.
 	p := Domite newElement: 'p'.
-	d insertDomite: p.
+	d << p.
 	s := Domite newElement: 'span'.
-	d insertDomite: s.
-	d clearHere.
-	d insertString: 'dom-mite'.
-	d clearHere.
-	d clearHere.
+	d << s.
+	d resetContents.
+	d << 'dom-mite'.
+	d resetContents.
+	d resetContents.
 	self assert: (document body innerHTML endsWith: '></div>')
 !
 
@@ -132,11 +132,11 @@ testMultipleInsertsWithClearInBetween
 	| d p s |
 	d := Domite fromElement: fixtureDiv.
 	p := Domite newElement: 'p'.
-	d insertDomite: p.
+	d << p.
 	s := Domite newElement: 'span'.
-	d insertDomite: s.
-	d clearHere.
-	d insertString: 'dom-mite'.
+	d << s.
+	d resetContents.
+	d << 'dom-mite'.
 	self assert: (document body innerHTML endsWith: '>dom-mite</div>')
 ! !
 

+ 147 - 99
src/DOMite.js

@@ -1,10 +1,10 @@
-define("domite/DOMite", ["amber/boot", "amber_core/Kernel-Objects"], function($boot){
+define("domite/DOMite", ["amber/boot", "amber_core/Kernel-Collections"], function($boot){
 var $core=$boot.api,nil=$boot.nil,$recv=$boot.asReceiver,$globals=$boot.globals;
 $core.addPackage('DOMite');
 $core.packages["DOMite"].innerEval = function (expr) { return eval(expr); };
 $core.packages["DOMite"].transport = {"type":"amd","amdNamespace":"domite"};
 
-$core.addClass('Domite', $globals.Object, ['element', 'reference'], 'DOMite');
+$core.addClass('Domite', $globals.ProtoStream, ['element', 'reference'], 'DOMite');
 //>>excludeStart("ide", pragmas.excludeIdeData);
 $globals.Domite.comment="I am (hopefully thin) wrapper around the notion of \x22cursor in a page\x22.\x0aI represent a DOM node _and_ a point where\x0ato insert new content into it.\x0a\x0aSo I play both the role of a container that inserts\x0aas well as the role of an element being inserted.\x0a\x0aCreation API:\x0a\x0a - `Domite new` creates an insertion point at the bottom of `<body>`.\x0a - `Domite open` is unique way to create pieces of content. It creates an instance \x22floating in thin air\x22 (wrapper around DOM DocumentFragment) that can be filled with any contents and then inserted in a page.\x0a - `Domite fromElement: aDomElement` wraps an element and set the cursor to its end.\x0a\x0aManipulation API:\x0a\x0a - `aDomite insertDomite:` and `aDomite insertString:` insert either a Domite or a text content at the insertion point.\x0a - `aDomite clearHere` deletes contents of the wrapped element.\x0a\x0aCursor moving API:\x0a\x0aTake this sample HTML, where `[n]` are just markers, not real content:\x0a\x0a```\x0a<body>\x0a  <h1>header</h1>\x0a  [4]<p>[2]Hello[1]world[3]</p>[5]\x0a  <small>footer</small>\x0a</body>\x0a```\x0a\x0aIf `d` is a `Domite` representing `[1]`, then:\x0a\x0a - `d seekHereStart` would move `d` to be at `[2]`,\x0a - `d seekHereEnd` would move `d` to be at `[3]`,\x0a - `d seekBeforeHere` would move `d` to be at `[4]`, and\x0a - `d seekAfterHere` would move `d` to be at `[5]`.\x0a\x0aIt is not presumed one would use `seekXxx`\x0ato actually move around in a single instance.\x0aIt is envisioned this API will be used mostly\x0ain combination with `copy`, like\x0a`afterMe := self copy seekAfterHere`.";
 //>>excludeEnd("ide");
@@ -65,7 +65,7 @@ $globals.Domite);
 
 $core.addMethod(
 $core.method({
-selector: "canSeekOutOfHere",
+selector: "canSetToUpperLevel",
 protocol: 'testing',
 fn: function (){
 var self=this;
@@ -76,45 +76,18 @@ var $1;
 $1=$recv($recv(self._element())._parentNode())._notNil();
 return $1;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"canSeekOutOfHere",{},$globals.Domite)});
+}, function($ctx1) {$ctx1.fill(self,"canSetToUpperLevel",{},$globals.Domite)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "canSeekOutOfHere\x0a\x09^ self element parentNode notNil",
+source: "canSetToUpperLevel\x0a\x09^ self element parentNode notNil",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: ["notNil", "parentNode", "element"]
 }),
 $globals.Domite);
 
-$core.addMethod(
-$core.method({
-selector: "clearHere",
-protocol: 'deletion',
-fn: function (){
-var self=this;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-return $core.withContext(function($ctx1) {
-//>>excludeEnd("ctx");
-
-	var element = self['@element'], child;
-	while (child = element.firstChild) element.removeChild(child);
-	self['@reference'] = null;;
-return self;
-//>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"clearHere",{},$globals.Domite)});
-//>>excludeEnd("ctx");
-},
-//>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "clearHere\x0a<\x0a\x09var element = self['@element'], child;\x0a\x09while (child = element.firstChild) element.removeChild(child);\x0a\x09self['@reference'] = null;\x0a>",
-referencedClasses: [],
-//>>excludeEnd("ide");
-messageSends: []
-}),
-$globals.Domite);
-
 $core.addMethod(
 $core.method({
 selector: "element",
@@ -189,98 +162,98 @@ $globals.Domite);
 
 $core.addMethod(
 $core.method({
-selector: "insertDomite:",
-protocol: 'insertion',
-fn: function (aDomite){
+selector: "isInvalid",
+protocol: 'testing',
+fn: function (){
 var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-self._insertElement_($recv(aDomite)._element());
-return self;
+var $1;
+$1=$recv(self._element())._isNil();
+return $1;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"insertDomite:",{aDomite:aDomite},$globals.Domite)});
+}, function($ctx1) {$ctx1.fill(self,"isInvalid",{},$globals.Domite)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aDomite"],
-source: "insertDomite: aDomite\x0a\x09self insertElement: aDomite element",
+args: [],
+source: "isInvalid\x0a\x09^ self element isNil",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["insertElement:", "element"]
+messageSends: ["isNil", "element"]
 }),
 $globals.Domite);
 
 $core.addMethod(
 $core.method({
-selector: "insertElement:",
+selector: "nextPut:",
 protocol: 'insertion',
-fn: function (aDomElement){
+fn: function (anObject){
 var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-$recv(self._element())._insertBefore_reference_(aDomElement,self._reference());
+self._nextPutString_($recv(anObject)._printString());
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"insertElement:",{aDomElement:aDomElement},$globals.Domite)});
+}, function($ctx1) {$ctx1.fill(self,"nextPut:",{anObject:anObject},$globals.Domite)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aDomElement"],
-source: "insertElement: aDomElement\x0a\x09self element\x0a\x09\x09insertBefore: aDomElement\x0a\x09\x09reference: self reference",
+args: ["anObject"],
+source: "nextPut: anObject\x0a\x09self nextPutString: anObject printString",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["insertBefore:reference:", "element", "reference"]
+messageSends: ["nextPutString:", "printString"]
 }),
 $globals.Domite);
 
 $core.addMethod(
 $core.method({
-selector: "insertString:",
+selector: "nextPutDomNode:",
 protocol: 'insertion',
-fn: function (aString){
+fn: function (aDomElement){
 var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-self._insertElement_($recv(document)._createTextNode_($recv(aString)._asString()));
+$recv(self._element())._insertBefore_reference_(aDomElement,self._reference());
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"insertString:",{aString:aString},$globals.Domite)});
+}, function($ctx1) {$ctx1.fill(self,"nextPutDomNode:",{aDomElement:aDomElement},$globals.Domite)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
-args: ["aString"],
-source: "insertString: aString\x0a\x09self insertElement: (\x0a\x09\x09document createTextNode: aString asString )",
+args: ["aDomElement"],
+source: "nextPutDomNode: aDomElement\x0a\x09self element\x0a\x09\x09insertBefore: aDomElement\x0a\x09\x09reference: self reference",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["insertElement:", "createTextNode:", "asString"]
+messageSends: ["insertBefore:reference:", "element", "reference"]
 }),
 $globals.Domite);
 
 $core.addMethod(
 $core.method({
-selector: "isInvalid",
-protocol: 'testing',
-fn: function (){
+selector: "nextPutString:",
+protocol: 'insertion',
+fn: function (aString){
 var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1;
-$1=$recv(self._element())._isNil();
-return $1;
+self._nextPutDomNode_($recv(document)._createTextNode_($recv(aString)._asString()));
+return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"isInvalid",{},$globals.Domite)});
+}, function($ctx1) {$ctx1.fill(self,"nextPutString:",{aString:aString},$globals.Domite)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
-args: [],
-source: "isInvalid\x0a\x09^ self element isNil",
+args: ["aString"],
+source: "nextPutString: aString\x0a\x09self nextPutDomNode: (\x0a\x09\x09document createTextNode: aString asString )",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["isNil", "element"]
+messageSends: ["nextPutDomNode:", "createTextNode:", "asString"]
 }),
 $globals.Domite);
 
@@ -382,6 +355,30 @@ messageSends: ["at:put:"]
 }),
 $globals.Domite);
 
+$core.addMethod(
+$core.method({
+selector: "putOn:",
+protocol: 'streaming',
+fn: function (aStream){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$recv(aStream)._nextPutDomNode_(self._element());
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"putOn:",{aStream:aStream},$globals.Domite)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aStream"],
+source: "putOn: aStream\x0a\x09aStream nextPutDomNode: self element",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["nextPutDomNode:", "element"]
+}),
+$globals.Domite);
+
 $core.addMethod(
 $core.method({
 selector: "reference",
@@ -423,110 +420,137 @@ $globals.Domite);
 
 $core.addMethod(
 $core.method({
-selector: "seekAfterHere",
-protocol: 'navigation',
+selector: "reset",
+protocol: 'positioning',
 fn: function (){
 var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $2,$1,$3;
-$2=self._element();
+self._reference_($recv(self._element())._firstChild());
+return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-$ctx1.sendIdx["element"]=1;
+}, function($ctx1) {$ctx1.fill(self,"reset",{},$globals.Domite)});
 //>>excludeEnd("ctx");
-$1=$recv($2)._nextSibling();
-self._reference_($1);
-$3=self._element_($recv(self._element())._parentNode());
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "reset\x0a\x09self reference: self element firstChild",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["reference:", "firstChild", "element"]
+}),
+$globals.Domite);
+
+$core.addMethod(
+$core.method({
+selector: "resetContents",
+protocol: 'deletion',
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+
+	var element = self['@element'], child;
+	while (child = element.firstChild) element.removeChild(child);
+	self['@reference'] = null;;
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"seekAfterHere",{},$globals.Domite)});
+}, function($ctx1) {$ctx1.fill(self,"resetContents",{},$globals.Domite)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "seekAfterHere\x0a\x09self\x0a\x09\x09reference: self element nextSibling;\x0a\x09\x09element: self element parentNode",
+source: "resetContents\x0a<\x0a\x09var element = self['@element'], child;\x0a\x09while (child = element.firstChild) element.removeChild(child);\x0a\x09self['@reference'] = null;\x0a>",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["reference:", "nextSibling", "element", "element:", "parentNode"]
+messageSends: []
 }),
 $globals.Domite);
 
 $core.addMethod(
 $core.method({
-selector: "seekBeforeHere",
-protocol: 'navigation',
+selector: "setToAfter",
+protocol: 'positioning',
 fn: function (){
 var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-var $1,$2;
-$1=self._element();
+var $2,$1,$3;
+$2=self._element();
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 $ctx1.sendIdx["element"]=1;
 //>>excludeEnd("ctx");
+$1=$recv($2)._nextSibling();
 self._reference_($1);
-$2=self._element_($recv(self._element())._parentNode());
+$3=self._element_($recv(self._element())._parentNode());
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"seekBeforeHere",{},$globals.Domite)});
+}, function($ctx1) {$ctx1.fill(self,"setToAfter",{},$globals.Domite)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "seekBeforeHere\x0a\x09self\x0a\x09\x09reference: self element;\x0a\x09\x09element: self element parentNode",
+source: "setToAfter\x0a\x09self\x0a\x09\x09reference: self element nextSibling;\x0a\x09\x09element: self element parentNode",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["reference:", "element", "element:", "parentNode"]
+messageSends: ["reference:", "nextSibling", "element", "element:", "parentNode"]
 }),
 $globals.Domite);
 
 $core.addMethod(
 $core.method({
-selector: "seekHereEnd",
-protocol: 'navigation',
+selector: "setToBefore",
+protocol: 'positioning',
 fn: function (){
 var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-self._reference_(nil._asJSON());
+var $1,$2;
+$1=self._element();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+$ctx1.sendIdx["element"]=1;
+//>>excludeEnd("ctx");
+self._reference_($1);
+$2=self._element_($recv(self._element())._parentNode());
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"seekHereEnd",{},$globals.Domite)});
+}, function($ctx1) {$ctx1.fill(self,"setToBefore",{},$globals.Domite)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "seekHereEnd\x0a\x09self reference: nil asJSON \x22null\x22",
+source: "setToBefore\x0a\x09self\x0a\x09\x09reference: self element;\x0a\x09\x09element: self element parentNode",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["reference:", "asJSON"]
+messageSends: ["reference:", "element", "element:", "parentNode"]
 }),
 $globals.Domite);
 
 $core.addMethod(
 $core.method({
-selector: "seekHereStart",
-protocol: 'navigation',
+selector: "setToEnd",
+protocol: 'positioning',
 fn: function (){
 var self=this;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
 return $core.withContext(function($ctx1) {
 //>>excludeEnd("ctx");
-self._reference_($recv(self._element())._firstChild());
+self._reference_(nil._asJSON());
 return self;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"seekHereStart",{},$globals.Domite)});
+}, function($ctx1) {$ctx1.fill(self,"setToEnd",{},$globals.Domite)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "seekHereStart\x0a\x09self reference: self element firstChild",
+source: "setToEnd\x0a\x09self reference: nil asJSON \x22null\x22",
 referencedClasses: [],
 //>>excludeEnd("ide");
-messageSends: ["reference:", "firstChild", "element"]
+messageSends: ["reference:", "asJSON"]
 }),
 $globals.Domite);
 
@@ -640,7 +664,7 @@ $globals.Domite.klass);
 
 $core.addMethod(
 $core.method({
-selector: "open",
+selector: "newStream",
 protocol: 'instance creation',
 fn: function (){
 var self=this;
@@ -651,16 +675,40 @@ var $1;
 $1=self._fromElement_($recv(document)._createDocumentFragment());
 return $1;
 //>>excludeStart("ctx", pragmas.excludeDebugContexts);
-}, function($ctx1) {$ctx1.fill(self,"open",{},$globals.Domite.klass)});
+}, function($ctx1) {$ctx1.fill(self,"newStream",{},$globals.Domite.klass)});
 //>>excludeEnd("ctx");
 },
 //>>excludeStart("ide", pragmas.excludeIdeData);
 args: [],
-source: "open\x0a\x09^ self fromElement: document createDocumentFragment",
+source: "newStream\x0a\x09^ self fromElement: document createDocumentFragment",
 referencedClasses: [],
 //>>excludeEnd("ide");
 messageSends: ["fromElement:", "createDocumentFragment"]
 }),
 $globals.Domite.klass);
 
+$core.addMethod(
+$core.method({
+selector: "nextPutDomNode:",
+protocol: '*DOMite',
+fn: function (aNode){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+self._nextPut_(aNode);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"nextPutDomNode:",{aNode:aNode},$globals.ProtoStream)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aNode"],
+source: "nextPutDomNode: aNode\x0a\x09self nextPut: aNode",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["nextPut:"]
+}),
+$globals.ProtoStream);
+
 });

+ 28 - 16
src/DOMite.st

@@ -1,5 +1,5 @@
 Smalltalk createPackage: 'DOMite'!
-Object subclass: #Domite
+ProtoStream subclass: #Domite
 	instanceVariableNames: 'element reference'
 	package: 'DOMite'!
 !Domite commentStamp!
@@ -84,7 +84,7 @@ reference: anObject
 
 !Domite methodsFor: 'deletion'!
 
-clearHere
+resetContents
 <
 	var element = self['@element'], child;
 	while (child = element.firstChild) element.removeChild(child);
@@ -112,46 +112,52 @@ initialize
 
 !Domite methodsFor: 'insertion'!
 
-insertDomite: aDomite
-	self insertElement: aDomite element
+nextPut: anObject
+	self nextPutString: anObject printString
 !
 
-insertElement: aDomElement
+nextPutDomNode: aDomElement
 	self element
 		insertBefore: aDomElement
 		reference: self reference
 !
 
-insertString: aString
-	self insertElement: (
+nextPutString: aString
+	self nextPutDomNode: (
 		document createTextNode: aString asString )
 ! !
 
-!Domite methodsFor: 'navigation'!
+!Domite methodsFor: 'positioning'!
 
-seekAfterHere
+reset
+	self reference: self element firstChild
+!
+
+setToAfter
 	self
 		reference: self element nextSibling;
 		element: self element parentNode
 !
 
-seekBeforeHere
+setToBefore
 	self
 		reference: self element;
 		element: self element parentNode
 !
 
-seekHereEnd
+setToEnd
 	self reference: nil asJSON "null"
-!
+! !
 
-seekHereStart
-	self reference: self element firstChild
+!Domite methodsFor: 'streaming'!
+
+putOn: aStream
+	aStream nextPutDomNode: self element
 ! !
 
 !Domite methodsFor: 'testing'!
 
-canSeekOutOfHere
+canSetToUpperLevel
 	^ self element parentNode notNil
 !
 
@@ -182,7 +188,13 @@ newElement: aString
 	^ self fromElement: (document createElement: aString)
 !
 
-open
+newStream
 	^ self fromElement: document createDocumentFragment
 ! !
 
+!ProtoStream methodsFor: '*DOMite'!
+
+nextPutDomNode: aNode
+	self nextPut: aNode
+! !
+