版博士V2.0程序
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

HTMLSelectElement.d.ts 4.8 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import HTMLElement from '../html-element/HTMLElement';
  2. import IHTMLFormElement from '../html-form-element/IHTMLFormElement';
  3. import ValidityState from '../validity-state/ValidityState';
  4. import IHTMLLabelElement from '../html-label-element/IHTMLLabelElement';
  5. import INodeList from '../node/INodeList';
  6. import IHTMLSelectElement from './IHTMLSelectElement';
  7. import Event from '../../event/Event';
  8. import IHTMLOptionElement from '../html-option-element/IHTMLOptionElement';
  9. import IHTMLOptGroupElement from '../html-opt-group-element/IHTMLOptGroupElement';
  10. import IHTMLOptionsCollection from '../html-option-element/IHTMLOptionsCollection';
  11. import INode from '../node/INode';
  12. /**
  13. * HTML Select Element.
  14. *
  15. * Reference:
  16. * https://developer.mozilla.org/en-US/docs/Web/API/HTMLSelectElement.
  17. */
  18. export default class HTMLSelectElement extends HTMLElement implements IHTMLSelectElement {
  19. labels: INodeList<IHTMLLabelElement>;
  20. readonly options: IHTMLOptionsCollection;
  21. onchange: (event: Event) => void | null;
  22. oninput: (event: Event) => void | null;
  23. /**
  24. * Returns name.
  25. *
  26. * @returns Name.
  27. */
  28. get name(): string;
  29. /**
  30. * Sets name.
  31. *
  32. * @param name Name.
  33. */
  34. set name(name: string);
  35. /**
  36. * Returns disabled.
  37. *
  38. * @returns Disabled.
  39. */
  40. get disabled(): boolean;
  41. /**
  42. * Sets disabled.
  43. *
  44. * @param disabled Disabled.
  45. */
  46. set disabled(disabled: boolean);
  47. /**
  48. * Returns multiple.
  49. *
  50. * @returns Multiple.
  51. */
  52. get multiple(): boolean;
  53. /**
  54. * Sets multiple.
  55. *
  56. * @param multiple Multiple.
  57. */
  58. set multiple(multiple: boolean);
  59. /**
  60. * Returns autofocus.
  61. *
  62. * @returns Autofocus.
  63. */
  64. get autofocus(): boolean;
  65. /**
  66. * Sets autofocus.
  67. *
  68. * @param autofocus Autofocus.
  69. */
  70. set autofocus(autofocus: boolean);
  71. /**
  72. * Returns length.
  73. *
  74. * @returns length.
  75. */
  76. get length(): number;
  77. /**
  78. * Sets length.
  79. *
  80. * @param length Length.
  81. */
  82. set length(length: number);
  83. /**
  84. * Returns required.
  85. *
  86. * @returns Required.
  87. */
  88. get required(): boolean;
  89. /**
  90. * Sets required.
  91. *
  92. * @param required Required.
  93. */
  94. set required(required: boolean);
  95. /**
  96. * Returns type.
  97. *
  98. * @returns type.
  99. */
  100. get type(): string;
  101. /**
  102. * Returns value.
  103. *
  104. * @returns Value.
  105. */
  106. get value(): string;
  107. /**
  108. * Sets value.
  109. *
  110. * @param value Value.
  111. */
  112. set value(value: string);
  113. /**
  114. * Returns value.
  115. *
  116. * @returns Value.
  117. */
  118. get selectedIndex(): number;
  119. /**
  120. * Sets value.
  121. *
  122. * @param selectedIndex Selected index.
  123. */
  124. set selectedIndex(selectedIndex: number);
  125. /**
  126. * Returns the parent form element.
  127. *
  128. * @returns Form.
  129. */
  130. get form(): IHTMLFormElement;
  131. /**
  132. * Returns validity state.
  133. *
  134. * @returns Validity state.
  135. */
  136. get validity(): ValidityState;
  137. /**
  138. * Returns "true" if it will validate.
  139. *
  140. * @returns "true" if it will validate.
  141. */
  142. get willValidate(): boolean;
  143. /**
  144. * Returns item from options collection by index.
  145. *
  146. * @param index Index.
  147. */
  148. item(index: number): IHTMLOptionElement | IHTMLOptGroupElement;
  149. /**
  150. * Adds new option to options collection.
  151. *
  152. * @param element HTMLOptionElement or HTMLOptGroupElement to add.
  153. * @param before HTMLOptionElement or index number.
  154. */
  155. add(element: IHTMLOptionElement | IHTMLOptGroupElement, before?: number | IHTMLOptionElement | IHTMLOptGroupElement): void;
  156. /**
  157. * Removes indexed element from collection or the select element.
  158. *
  159. * @param [index] Index.
  160. */
  161. remove(index?: number): void;
  162. /**
  163. * @override
  164. */
  165. appendChild(node: INode): INode;
  166. /**
  167. * @override
  168. */
  169. insertBefore(newNode: INode, referenceNode: INode | null): INode;
  170. /**
  171. * @override
  172. */
  173. removeChild(node: INode): INode;
  174. /**
  175. * Resets the option selectedness.
  176. *
  177. * Based on:
  178. * https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/nodes/HTMLSelectElement-impl.js
  179. *
  180. * @param [newOption] Optional new option element to be selected.
  181. * @see https://html.spec.whatwg.org/multipage/form-elements.html#selectedness-setting-algorithm
  182. */
  183. _resetOptionSelectednes(newOption?: IHTMLOptionElement): void;
  184. /**
  185. * Returns display size.
  186. *
  187. * @returns Display size.
  188. */
  189. protected _getDisplaySize(): number;
  190. /**
  191. * Updates index properties.
  192. *
  193. * @param previousLength Length before the update.
  194. * @param newLength Length after the update.
  195. */
  196. protected _updateIndexProperties(previousLength: number, newLength: number): void;
  197. }