Debug: detectar contenedor anidado cuando doc-body no tiene esquema-sep como hijo directo

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-10 12:03:58 -05:00
co-authored by Claude Sonnet 4.6
parent f22553391c
commit ee1cd684a8
+21 -3
View File
@@ -1320,12 +1320,30 @@ function _mpApplyExamVisibility(selectedExam) {
// (no querySelectorAll — así capturamos section-title y otros sin data-campo-id)
var docBody = document.querySelector('.doc-body');
if (!docBody) { console.warn('[tomas] .doc-body no encontrado'); return; }
// Encontrar el contenedor real donde están los campos
var fieldContainer = docBody;
var children = Array.from(docBody.children);
console.log('[tomas] docBody.children.length:', children.length,
'| seps en children:', children.filter(function(c){return c.classList.contains('esquema-sep');}).length);
var sepsInChildren = children.filter(function(c){return c.classList.contains('esquema-sep');}).length;
console.log('[tomas] docBody.children.length:', children.length, '| seps en children:', sepsInChildren);
if (sepsInChildren === 0 && children.length > 0) {
// Los campos están anidados — buscar el contenedor que tenga esquema-sep
var found = null;
children.forEach(function(child) {
if (!found && child.querySelector('.esquema-sep')) found = child;
});
if (found) {
fieldContainer = found;
console.log('[tomas] usando contenedor anidado:', found.tagName, found.className);
} else {
// Intentar con querySelectorAll en todo el doc-body
console.warn('[tomas] no se encontró .esquema-sep en hijos directos, usando querySelectorAll fallback');
fieldContainer = null;
}
}
var childList = fieldContainer ? Array.from(fieldContainer.children) : [];
var inHidden = false;
var hiddenCount = 0;
children.forEach(function(child) {
childList.forEach(function(child) {
if (child.classList.contains('esquema-sep')) {
var cid = child.getAttribute('data-campo-id') || '';
if (allTomaSeps[cid] !== undefined) {