Browse Source

More convenience methods in PlatformDom class.

Herbert Vojčík 7 years ago
parent
commit
2c1e5b1daf
3 changed files with 60 additions and 0 deletions
  1. 2 0
      API-CHANGES.txt
  2. 48 0
      src/Platform-DOM.js
  3. 10 0
      src/Platform-DOM.st

+ 2 - 0
API-CHANGES.txt

@@ -9,6 +9,8 @@
   + newDocumentFragment
   + newElement:
   + newTextNode:
+  + newCustomEvent:detail:
+  + toArray:
 + CharacterArray >>
   + asDomNode
 + Collection >>

+ 48 - 0
src/Platform-DOM.js

@@ -69,6 +69,30 @@ messageSends: []
 }),
 $globals.PlatformDom.klass);
 
+$core.addMethod(
+$core.method({
+selector: "newCustomEvent:detail:",
+protocol: 'node creation',
+fn: function (aString,anObject){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return new CustomEvent(aString, {detail: anObject});
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"newCustomEvent:detail:",{aString:aString,anObject:anObject},$globals.PlatformDom.klass)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aString", "anObject"],
+source: "newCustomEvent: aString detail: anObject\x0a<inlineJS: 'return new CustomEvent(aString, {detail: anObject})'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.PlatformDom.klass);
+
 $core.addMethod(
 $core.method({
 selector: "newDocumentFragment",
@@ -141,6 +165,30 @@ messageSends: []
 }),
 $globals.PlatformDom.klass);
 
+$core.addMethod(
+$core.method({
+selector: "toArray:",
+protocol: 'converting',
+fn: function (aDomList){
+var self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return Array.prototype.slice.call(aDomList);
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"toArray:",{aDomList:aDomList},$globals.PlatformDom.klass)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aDomList"],
+source: "toArray: aDomList\x0a<inlineJS: 'return Array.prototype.slice.call(aDomList)'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.PlatformDom.klass);
+
 $core.addMethod(
 $core.method({
 selector: "asDomNode",

+ 10 - 0
src/Platform-DOM.st

@@ -3,8 +3,18 @@ Object subclass: #PlatformDom
 	instanceVariableNames: ''
 	package: 'Platform-DOM'!
 
+!PlatformDom class methodsFor: 'converting'!
+
+toArray: aDomList
+<inlineJS: 'return Array.prototype.slice.call(aDomList)'>
+! !
+
 !PlatformDom class methodsFor: 'node creation'!
 
+newCustomEvent: aString detail: anObject
+<inlineJS: 'return new CustomEvent(aString, {detail: anObject})'>
+!
+
 newDocumentFragment
 <inlineJS: 'return document.createDocumentFragment()'>
 !