Platform-DOM.st 659 B

123456789101112131415161718192021222324252627282930
  1. Smalltalk createPackage: 'Platform-DOM'!
  2. Object subclass: #PlatformDom
  3. instanceVariableNames: ''
  4. package: 'Platform-DOM'!
  5. !PlatformDom class methodsFor: 'testing'!
  6. isDomNode: anObject
  7. <inlineJS: '
  8. return anObject.nodeType > 0 &&
  9. Object.prototype.toString.call(anObject) !!== "[object Object]"
  10. '>
  11. !
  12. isFeasible
  13. <inlineJS: '
  14. if (typeof document === "undefined") return false;
  15. try {
  16. var d = document.createElement("div"),
  17. f = document.createDocumentFragment(),
  18. t = document.createTextNode("Hello, Amber!!");
  19. f.appendChild(t);
  20. d.insertBefore(f, null);
  21. return d.innerHTML === "Hello, Amber!!";
  22. } catch (e) {
  23. return false;
  24. }
  25. '>
  26. ! !