- Issue created by @stomusic
- @stomusic opened merge request.
- 🇮🇳India abhishek@kumar
Simplified Iterator Approach
(function (Drupal) { Drupal.behaviors.smartImagingStyles = { attach: function (context, settings) { // Process all picture elements const pictures = once('smart-imaging-styles', 'picture', context); pictures.forEach(picture => { // Process all source elements within each picture const sources = picture.querySelectorAll('source'); sources.forEach(source => { // Your processing logic for each source const srcset = source.getAttribute('srcset'); if (srcset) { // Apply transformations to each srcset const transformedSrcset = this.transformSrcset(srcset); source.setAttribute('srcset', transformedSrcset); } }); }); }, transformSrcset: function(srcset) { // Your srcset transformation logic here return srcset; // Return modified srcset } }; })(Drupal);