|
@@ -8,6 +8,61 @@ $core.addClass('Domite', $globals.Object, ['element', 'reference'], 'DOMite');
|
|
//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
//>>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`.";
|
|
$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");
|
|
//>>excludeEnd("ide");
|
|
|
|
+$core.addMethod(
|
|
|
|
+$core.method({
|
|
|
|
+selector: "attrAt:",
|
|
|
|
+protocol: 'accessing',
|
|
|
|
+fn: function (aString){
|
|
|
|
+var self=this;
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+var $1,$2;
|
|
|
|
+$1=$recv(self["@element"])._hasAttribute_(aString);
|
|
|
|
+if($core.assert($1)){
|
|
|
|
+$2=$recv(self["@element"])._getAttribute_(aString);
|
|
|
|
+return $2;
|
|
|
|
+} else {
|
|
|
|
+return nil;
|
|
|
|
+};
|
|
|
|
+return self;
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"attrAt:",{aString:aString},$globals.Domite)});
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+},
|
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
|
+args: ["aString"],
|
|
|
|
+source: "attrAt: aString\x0a\x09(element hasAttribute: aString)\x0a\x09\x09ifTrue: [ ^ element getAttribute: aString ]\x0a\x09\x09ifFalse: [ ^ nil ]",
|
|
|
|
+referencedClasses: [],
|
|
|
|
+//>>excludeEnd("ide");
|
|
|
|
+messageSends: ["ifTrue:ifFalse:", "hasAttribute:", "getAttribute:"]
|
|
|
|
+}),
|
|
|
|
+$globals.Domite);
|
|
|
|
+
|
|
|
|
+$core.addMethod(
|
|
|
|
+$core.method({
|
|
|
|
+selector: "attrAt:put:",
|
|
|
|
+protocol: 'accessing',
|
|
|
|
+fn: function (aString,anotherString){
|
|
|
|
+var self=this;
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+$recv(self["@element"])._setAttribute_to_(aString,anotherString);
|
|
|
|
+return self;
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"attrAt:put:",{aString:aString,anotherString:anotherString},$globals.Domite)});
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+},
|
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
|
+args: ["aString", "anotherString"],
|
|
|
|
+source: "attrAt: aString put: anotherString\x0a\x09element setAttribute: aString to: anotherString",
|
|
|
|
+referencedClasses: [],
|
|
|
|
+//>>excludeEnd("ide");
|
|
|
|
+messageSends: ["setAttribute:to:"]
|
|
|
|
+}),
|
|
|
|
+$globals.Domite);
|
|
|
|
+
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "canSeekOutOfHere",
|
|
selector: "canSeekOutOfHere",
|
|
@@ -277,6 +332,56 @@ messageSends: ["addEventListener:block:useCapture:"]
|
|
}),
|
|
}),
|
|
$globals.Domite);
|
|
$globals.Domite);
|
|
|
|
|
|
|
|
+$core.addMethod(
|
|
|
|
+$core.method({
|
|
|
|
+selector: "propAt:",
|
|
|
|
+protocol: 'accessing',
|
|
|
|
+fn: function (aString){
|
|
|
|
+var self=this;
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+var $1;
|
|
|
|
+$1=$recv(self["@element"])._at_(aString);
|
|
|
|
+return $1;
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"propAt:",{aString:aString},$globals.Domite)});
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+},
|
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
|
+args: ["aString"],
|
|
|
|
+source: "propAt: aString\x0a\x09^ element at: aString",
|
|
|
|
+referencedClasses: [],
|
|
|
|
+//>>excludeEnd("ide");
|
|
|
|
+messageSends: ["at:"]
|
|
|
|
+}),
|
|
|
|
+$globals.Domite);
|
|
|
|
+
|
|
|
|
+$core.addMethod(
|
|
|
|
+$core.method({
|
|
|
|
+selector: "propAt:put:",
|
|
|
|
+protocol: 'accessing',
|
|
|
|
+fn: function (aString,anObject){
|
|
|
|
+var self=this;
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+return $core.withContext(function($ctx1) {
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+var $1;
|
|
|
|
+$1=$recv(self["@element"])._at_put_(aString,anObject);
|
|
|
|
+return $1;
|
|
|
|
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
|
|
|
|
+}, function($ctx1) {$ctx1.fill(self,"propAt:put:",{aString:aString,anObject:anObject},$globals.Domite)});
|
|
|
|
+//>>excludeEnd("ctx");
|
|
|
|
+},
|
|
|
|
+//>>excludeStart("ide", pragmas.excludeIdeData);
|
|
|
|
+args: ["aString", "anObject"],
|
|
|
|
+source: "propAt: aString put: anObject\x0a\x09^ element at: aString put: anObject",
|
|
|
|
+referencedClasses: [],
|
|
|
|
+//>>excludeEnd("ide");
|
|
|
|
+messageSends: ["at:put:"]
|
|
|
|
+}),
|
|
|
|
+$globals.Domite);
|
|
|
|
+
|
|
$core.addMethod(
|
|
$core.addMethod(
|
|
$core.method({
|
|
$core.method({
|
|
selector: "reference",
|
|
selector: "reference",
|