1. 1 : /**
  2. 2 : * Représente un LI
  3. 3 : */
  4. 4 : export class html_li extends mel_html2 {
  5. 5 : /**
  6. 6 : * Constructeur de la classe
  7. 7 : * @param {Object} options - Les options du constructeur.
  8. 8 : * @param {Object} options.attribs - Attributs de l'élément
  9. 9 : */
  10. 10 : constructor({attribs={}, contents=[]}) {
  11. 11 : super('li', {attribs, contents});
  12. 12 : }
  13. 13 : }
  14. 14 :
  15. 15 : /**
  16. 16 : * Représente un UL.
  17. 17 : *
  18. 18 : * Seul des LI peuvent être ajoutés.
  19. 19 : */
  20. 20 : export class html_ul extends mel_html2 {
  21. 21 : constructor({attribs={}}) {
  22. 22 : super('ul', {attribs, contents:[]});
  23. 23 : }
  24. 24 :
  25. 25 : /**
  26. 26 : * Ajoute un li à la liste des li
  27. 27 : * @param {Object} options - Les options du constructeur.
  28. 28 : * @param {Object} options.attribs - Attributs de l'élément
  29. 29 : * @returns {html_li} Li ajouter
  30. 30 : */
  31. 31 : li({attribs={}, contents=[]}) {
  32. 32 : const li = new html_li({attribs, contents});
  33. 33 : this.addContent(li);
  34. 34 : return li;
  35. 35 : }
  36. 36 :
  37. 37 : /**
  38. 38 : * Ajoute un élément enfant
  39. 39 : * @param {html_li} mel_html Elément à ajouter
  40. 40 : * @returns Chaînage
  41. 41 : */
  42. 42 : addContent(mel_html) {
  43. 43 : super.addContent(mel_html);
  44. 44 : if (!(mel_html instanceof html_li)) {
  45. 45 : delete this.jcontents[this.count() - 1];
  46. 46 : throw {msg:'Seul un li peut-être ajouter !', errored:[this, mel_html]};
  47. 47 : }
  48. 48 : return this;
  49. 49 : }
  50. 50 : }