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