Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

157 строки
3.7 KiB

  1. type Comment := {
  2. data: String,
  3. length: Number,
  4. nodeName: "#comment",
  5. nodeType: 8,
  6. nodeValue: String,
  7. ownerDoucment: null | Document,
  8. toString: (this: Comment) => String
  9. }
  10. type DOMText := {
  11. data: String,
  12. type: "DOMTextNode",
  13. length: Number,
  14. nodeType: 3,
  15. toString: (this: DOMText) => String,
  16. replaceChild: (
  17. this: DOMText,
  18. index: Number,
  19. length: Number,
  20. value: String
  21. ) => void
  22. }
  23. type DOMNode := DOMText | DOMElement | DocumentFragment
  24. type DOMChild := DOMText | DOMElement
  25. type DOMElement := {
  26. tagName: String,
  27. className: String,
  28. dataset: Object<String, Any>,
  29. childNodes: Array<DOMChild>,
  30. parentNode: null | DOMElement,
  31. style: Object<String, String>,
  32. type: "DOMElement",
  33. nodeType: 1,
  34. ownerDoucment: null | Document,
  35. namespaceURI: null | String,
  36. appendChild: (this: DOMElement, child: DOMChild) => DOMChild,
  37. replaceChild:(
  38. this: DOMElement,
  39. elem: DOMChild,
  40. needle: DOMChild
  41. ) => DOMChild,
  42. removeChild: (this: DOMElement, child: DOMChild) => DOMChild,
  43. insertBefore: (
  44. this: DOMElement,
  45. elem: DOMChild,
  46. needle: DOMChild | null | undefined
  47. ) => DOMChild,
  48. addEventListener: addEventListener,
  49. dispatchEvent: dispatchEvent,
  50. focus: () => void,
  51. toString: (this: DOMElement) => String,
  52. getElementsByClassName: (
  53. this: DOMElement,
  54. className: String
  55. ) => Array<DOMElement>,
  56. getElementsByTagName: (
  57. this: DOMElement,
  58. tagName: String
  59. ) => Array<DOMElement>,
  60. }
  61. type DocumentFragment := {
  62. childNodes: Array<DOMChild>,
  63. parentNode: null | DOMElement,
  64. type: "DocumentFragment",
  65. nodeType: 11,
  66. nodeName: "#document-fragment",
  67. ownerDoucment: Document | null,
  68. appendChild: (this: DocumentFragment, child: DOMChild),
  69. replaceChild:
  70. (this: DocumentFragment, elem: DOMChild, needle: DOMChild),
  71. removeChild: (this: DocumentFragment, child: DOMChild),
  72. toString: (this: DocumentFragment) => String
  73. }
  74. type Document := {
  75. body: DOMElement,
  76. childNodes: Array<DOMChild>,
  77. documentElement: DOMElement,
  78. nodeType: 9,
  79. createComment: (this: Document, data: String) => Commment,
  80. createTextNode: (this: Document, value: String) => DOMText,
  81. createElement: (this: Document, tagName: String) => DOMElement,
  82. createElementNS: (
  83. this: Document,
  84. namespace: String | null,
  85. tagName: String
  86. ) => DOMElement,
  87. createDocumentFragment: (this: Document) => DocumentFragment,
  88. createEvent: () => Event,
  89. getElementById: (
  90. this: Document,
  91. id: String,
  92. ) => null | DOMElement,
  93. getElementsByClassName: (
  94. this: Document,
  95. className: String
  96. ) => Array<DOMElement>,
  97. getElementsByTagName: (
  98. this: Document,
  99. tagName: String
  100. ) => Array<DOMElement>
  101. }
  102. type Event := {
  103. type: String,
  104. bubbles: Boolean,
  105. cancelable: Boolean,
  106. initEvent: (
  107. this: Event,
  108. type: String,
  109. bubbles: Boolean,
  110. cancelable: Boolean
  111. ) => void
  112. }
  113. type addEventListener := (
  114. this: DOMElement,
  115. type: String,
  116. listener: Listener
  117. ) => void
  118. type dispatchEvent := (
  119. this: DOMElement,
  120. ev: Event
  121. )
  122. min-document/event/add-event-listener := addEventListener
  123. min-document/event/dispatch-event := dispatchEvent
  124. min-document/document := () => Document
  125. min-document/dom-element :=
  126. (tagName: String, owner?: Document, namespace?: String | null) => DOMElement
  127. min-document/dom-fragment :=
  128. (owner?: Document) => DocumentFragment
  129. min-document/dom-text :=
  130. (value: String, owner?: Document) => DOMText
  131. min-document/event := () => Event
  132. min-document/serialize := (DOMElement) => String
  133. min-document := Document