@@ -238,14 +238,14 @@ export function renameElement(doc, oldName, newName, xpathContext = XPATH_CONTEX
238238 for ( let element of elements ) {
239239 const newElement = doc . createElement ( newName )
240240 copyAttributes ( element , newElement )
241-
241+
242242 // Add new attributes if specified
243243 if ( attributes && typeof attributes === 'object' ) {
244244 Object . entries ( attributes ) . forEach ( ( [ name , value ] ) => {
245245 newElement . setAttribute ( name , value )
246246 } )
247247 }
248-
248+
249249 moveChildren ( element , newElement )
250250 element . parentNode . replaceChild ( newElement , element )
251251 }
@@ -254,7 +254,7 @@ export function renameElement(doc, oldName, newName, xpathContext = XPATH_CONTEX
254254}
255255
256256/**
257- * Recursively remove empty elements (no attributes, no text, no meaningful children)
257+ * Recursively remove empty elements (no text, no children with text )
258258 * This prevents validation errors from empty required elements and cleans up output
259259 *
260260 * @param {Document } doc - XML DOM document
@@ -525,13 +525,13 @@ export function convertNamePartDate(doc) {
525525 for ( let element of namePartDates ) {
526526 const newElement = doc . createElement ( 'namePart' )
527527 newElement . setAttribute ( 'type' , 'date' )
528-
528+
529529 // Copy attributes from original element
530530 copyAttributes ( element , newElement )
531-
531+
532532 // Move children (text nodes and elements)
533533 moveChildren ( element , newElement )
534-
534+
535535 // Replace the old element with the new one
536536 element . parentNode . replaceChild ( newElement , element )
537537 }
@@ -632,7 +632,7 @@ export function toStrictMODS(xmlString) {
632632 // Remove non-standard attributes
633633 removeAttribute ( doc , XPATH_CONTEXTS . ACCESS_CONDITION , 'href' )
634634
635- // Remove all empty elements (no attributes, no text, no meaningful children)
635+ // Remove all empty elements (no text, no children with text )
636636 removeEmptyElements ( doc )
637637
638638 // Extract mods element and add namespace (for validation)
0 commit comments