Browse Source

PlatformDom >> newXxx.

Herbert Vojčík 7 years ago
parent
commit
5029ce4d67
3 changed files with 89 additions and 0 deletions
  1. 3 0
      API-CHANGES.txt
  2. 72 0
      src/Platform-DOM.js
  3. 14 0
      src/Platform-DOM.st

+ 3 - 0
API-CHANGES.txt

@@ -6,6 +6,9 @@
 + PlatformDom class >>
   + isFeasible
   + isDomNode:
+  + newDocumentFragment
+  + newElement:
+  + newTextNode:
 
 
 0.18.1:

+ 72 - 0
src/Platform-DOM.js

@@ -69,4 +69,76 @@ messageSends: []
 }),
 $globals.PlatformDom.klass);
 
+$core.addMethod(
+$core.method({
+selector: "newDocumentFragment",
+protocol: 'node creation',
+fn: function (){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return document.createDocumentFragment();
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"newDocumentFragment",{},$globals.PlatformDom.klass)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "newDocumentFragment\x0a<inlineJS: 'return document.createDocumentFragment()'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.PlatformDom.klass);
+
+$core.addMethod(
+$core.method({
+selector: "newElement:",
+protocol: 'node creation',
+fn: function (aString){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return document.createElement(aString);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"newElement:",{aString:aString},$globals.PlatformDom.klass)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString"],
+source: "newElement: aString\x0a<inlineJS: 'return document.createElement(aString)'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.PlatformDom.klass);
+
+$core.addMethod(
+$core.method({
+selector: "newTextNode:",
+protocol: 'node creation',
+fn: function (aString){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return document.createTextNode(aString);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"newTextNode:",{aString:aString},$globals.PlatformDom.klass)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString"],
+source: "newTextNode: aString\x0a<inlineJS: 'return document.createTextNode(aString)'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.PlatformDom.klass);
+
 });

+ 14 - 0
src/Platform-DOM.st

@@ -3,6 +3,20 @@ Object subclass: #PlatformDom
 	instanceVariableNames: ''
 	package: 'Platform-DOM'!
 
+!PlatformDom class methodsFor: 'node creation'!
+
+newDocumentFragment
+<inlineJS: 'return document.createDocumentFragment()'>
+!
+
+newElement: aString
+<inlineJS: 'return document.createElement(aString)'>
+!
+
+newTextNode: aString
+<inlineJS: 'return document.createTextNode(aString)'>
+! !
+
 !PlatformDom class methodsFor: 'testing'!
 
 isDomNode: anObject