codigo0/node_modules/happy-dom/lib/nodes/html-document/HTMLDocument.js
planetazuzu 5d7a6500fe refactor: Fase 1 - Clean Architecture, refactorización modular y eliminación de duplicidades
-  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
2026-01-25 21:09:47 +01:00

54 lines
2.4 KiB
JavaScript

import Document from '../document/Document.js';
import * as PropertySymbol from '../../PropertySymbol.js';
import NodeTypeEnum from '../node/NodeTypeEnum.js';
/**
* Document.
*/
export default class HTMLDocument extends Document {
/**
* Constructor.
*/
constructor() {
super();
// Default document elements
const documentElement = this.createElement('html');
const bodyElement = this.createElement('body');
const headElement = this.createElement('head');
this.appendChild(documentElement);
documentElement.appendChild(headElement);
documentElement.appendChild(bodyElement);
}
/**
* @override
*/
[PropertySymbol.appendChild](node, disableValidations = false) {
if (node[PropertySymbol.nodeType] === NodeTypeEnum.textNode) {
throw new this[PropertySymbol.window].Error(`Failed to execute 'appendChild' on 'Node': Nodes of type '#text' may not be inserted inside nodes of type '#document'.`);
}
if (node[PropertySymbol.nodeType] === NodeTypeEnum.documentFragmentNode) {
return node;
}
if (node[PropertySymbol.nodeType] === NodeTypeEnum.elementNode &&
this[PropertySymbol.elementArray].length !== 0) {
throw new this[PropertySymbol.window].Error(`Failed to execute 'appendChild' on 'Node': Only one element on document allowed.`);
}
return super[PropertySymbol.appendChild](node, disableValidations);
}
/**
* @override
*/
[PropertySymbol.insertBefore](newNode, referenceNode, disableValidations = false) {
if (newNode[PropertySymbol.nodeType] === NodeTypeEnum.textNode) {
throw new this[PropertySymbol.window].Error(`Failed to execute 'insertBefore' on 'Node': Nodes of type '#text' may not be inserted inside nodes of type '#document'.`);
}
if (newNode[PropertySymbol.nodeType] === NodeTypeEnum.documentFragmentNode) {
return newNode;
}
if (newNode[PropertySymbol.nodeType] === NodeTypeEnum.elementNode &&
this[PropertySymbol.elementArray].length !== 0) {
throw new this[PropertySymbol.window].Error(`Failed to execute 'insertBefore' on 'Node': Only one element on document allowed.`);
}
return super[PropertySymbol.insertBefore](newNode, referenceNode, disableValidations);
}
}
//# sourceMappingURL=HTMLDocument.js.map