- ✅ Ticket 1.1: Estructura Clean Architecture en backend - ✅ Ticket 1.2: Schemas Zod compartidos - ✅ Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares) - ✅ Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares) - ✅ Ticket 1.5: Eliminación de duplicidades (~50 líneas) Cambios principales: - Creada estructura Clean Architecture en backend/src/ - Schemas Zod compartidos en backend/src/shared/schemas/ - Refactorización modular de drugs y procedures - Utilidades genéricas en src/utils/ (filter, validation) - Eliminados scripts obsoletos y documentación antigua - Corregidos errores: QueryClient, import test-error-handling - Build verificado y funcionando correctamente
62 lines
3.2 KiB
JavaScript
62 lines
3.2 KiB
JavaScript
import QuerySelector from '../../query-selector/QuerySelector.js';
|
|
import * as PropertySymbol from '../../PropertySymbol.js';
|
|
import HTMLElement from '../html-element/HTMLElement.js';
|
|
import DOMExceptionNameEnum from '../../exception/DOMExceptionNameEnum.js';
|
|
/**
|
|
* HTMLTableSectionElement
|
|
*
|
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLTableSectionElement
|
|
*/
|
|
export default class HTMLTableSectionElement extends HTMLElement {
|
|
/**
|
|
* Returns an HTMLTableRowElement representing a new row of the table. It inserts it in the rows collection immediately before the <tr> element at the given index position. If the index is -1, the new row is appended to the collection. If the index is smaller than -1 or greater than the number of rows in the collection, a DOMException with the value IndexSizeError is raised.
|
|
*
|
|
* @param [index] Index.
|
|
* @returns Row.
|
|
*/
|
|
insertRow(index = -1) {
|
|
if (typeof index !== 'number') {
|
|
index = -1;
|
|
}
|
|
const rows = QuerySelector.querySelectorAll(this, 'tr')[PropertySymbol.items];
|
|
if (index < -1) {
|
|
throw new this[PropertySymbol.window].DOMException(`Failed to execute 'insertRow' on 'HTMLTableSectionElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum.indexSizeError);
|
|
}
|
|
if (index > rows.length) {
|
|
throw new this[PropertySymbol.window].DOMException(`Failed to execute 'insertRow' on 'HTMLTableSectionElement': The index provided (${index}) is greater than the number of rows (${rows.length}).`, DOMExceptionNameEnum.indexSizeError);
|
|
}
|
|
const row = this[PropertySymbol.ownerDocument].createElement('tr');
|
|
if (index === -1 || index === rows.length) {
|
|
this.appendChild(row);
|
|
}
|
|
else {
|
|
this.insertBefore(row, rows[index]);
|
|
}
|
|
return row;
|
|
}
|
|
/**
|
|
* Removes the row corresponding to the index given in parameter. If the index value is -1 the last row is removed; if it is smaller than -1 or greater than the amount of rows in the collection, a DOMException with the value IndexSizeError is raised.
|
|
*
|
|
* @param index Index.
|
|
*/
|
|
deleteRow(index) {
|
|
if (arguments.length === 0) {
|
|
throw new this[PropertySymbol.window].TypeError("Failed to execute 'deleteRow' on 'HTMLTableSectionElement': 1 argument required, but only 0 present.");
|
|
}
|
|
if (typeof index !== 'number') {
|
|
index = -1;
|
|
}
|
|
if (index < -1) {
|
|
throw new this[PropertySymbol.window].DOMException(`Failed to execute 'deleteRow' on 'HTMLTableSectionElement': The index provided (${index}) is less than -1.`, DOMExceptionNameEnum.indexSizeError);
|
|
}
|
|
const rows = QuerySelector.querySelectorAll(this, 'tr')[PropertySymbol.items];
|
|
if (index >= rows.length) {
|
|
throw new this[PropertySymbol.window].DOMException(`Failed to execute 'deleteRow' on 'HTMLTableSectionElement': The index provided (${index}) is greater than the number of rows in the table (${rows.length}).`, DOMExceptionNameEnum.indexSizeError);
|
|
}
|
|
if (index === -1) {
|
|
index = rows.length - 1;
|
|
}
|
|
rows[index].remove();
|
|
}
|
|
}
|
|
//# sourceMappingURL=HTMLTableSectionElement.js.map
|