1(function(){ 2 3 /** 4 * What needs to happen now: 5 * The "last" text-image-container is now contained within a block area, 6 * which means that we need to update our script. 7 * We need to check each block area: 8 * - If the current one contains a block area, keep it tracked/stored, and move on 9 * - If the current one does not, untrack/unstore it, and do the following: 10 * - If we have a previous block area with a text-image-container, set 11 * that text-image-container to "last" 12 * - If we do not have a previous block area with a text-image-container, 13 * proceed as usual. 14 */ 15 16 const $blockAreas = document.querySelectorAll('.block-type-block-area'); 17 let previousBlockArea = null; 18 const classTextImage = 'text-image-container'; 19 const classTextImageLast = classTextImage + '--last'; 20 21 const hasTextImageContainer = (item) => { 22 let result = false; 23 item.childNodes.forEach(child => { 24 if (child.classList && child.classList.contains(classTextImage)) { 25 result = true; 26 } 27 }); 28 return result; 29 }; 30 31 $blockAreas.forEach(blockArea => { 32 if (hasTextImageContainer(blockArea)) { 33 // Contains text-image-container, so for now, keep it as it is... 34 previousBlockArea = blockArea; 35 // Continue: 36 return true; 37 } 38 // Here, it does not contain one, so we need to check if we have a previous one: 39 if ( ! previousBlockArea) { 40 // Continue: 41 return true; 42 } 43 // There IS a previous one: 44 // Set the previous one's text-image-container as last! 45 previousBlockArea.querySelector('.text-image-container').classList.add(classTextImageLast); 46 // Don't forget to set the previous one to null! 47 previousBlockArea = null; 48 }); 49 50 // If, after the loop, we still have one, it means it was the last one of the block 51 // areas, which incidentally contains such a text-image, so we'll set it up as well! 52 if (previousBlockArea) { 53 previousBlockArea.querySelector('.text-image-container').classList.add(classTextImageLast); 54 } 55})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.