keen slider wont initialize correctly

I imported the keen slider js into our current project and configured an own javascript to form and initialize the sliders. It works quite fine for most of the sliders, just not for this specific case: a javascript which alters an array of elements based on the users actions. The keen slider seemingly cant deal with this (instead of one row, the slider renders multiple rows ontop of each other. The arrows are insanely buggy too.) and i just cant seem to figure out why. I will post 1: The javascript which renders the slider items after document ready // whenever the user searches something and the function of the delete button on the slides, which works flawlessly at least. 2: the keenslider.js i wrote myself to initialize the sliders. It just feels like im missing something silly since im rather new to javascript and jquery. Im also sorry if this question is put terribly, i dont know which informations are important to give yet.

1:

/**
     * renders markup for the last searches from the array of the last history items
     * @param searchHistoryData
     * @return {string|null}
     */
    renderSearchHistoryContainers(searchHistoryData) {

        if (searchHistoryData === null) return null;

        var containers = [];
        for (var k in searchHistoryData) {
            if (searchHistoryData.hasOwnProperty(k)) {
                var sh = searchHistoryData[k];
                // Regionsgruppen als [] beachten
                // var locationId = ($.type(sh.loc_id) === 'array' ? sh.loc_id.join('-') : sh.loc_id);
                // var id = k + '_' + sh.loc_key + '_' + locationId;
                var imageId = this.createDestinationImageKey(k, sh);

                var markup = '<div class="keen-slider__slide mb-1">n' +
                    '<div class="col">n' +
                    '<div class="card offer-card shadow-sm">n' +
                    '<div class="d-flex"> ' +
                    '<div class="text-dark text-truncate pt-2 ps-2"> ' + sh.title + '</div>' +
                    '<i data-key="' + k + '" class="ms-auto p-2 ps-4 far fa-xmark my-auto fw-light cursor-p searchHistoryDeleteButton" style="z-index: 99;"></i>n' +
                    '</div>n' +
                    '<a class="row g-0 p-2 text-decoration-none stretched-link" href="' + sh.url + '" title="Suche nach ' + sh.title + ' ausführen">n' +
                    '<div class="col-auto">n' +
                    '<div class="d-flex justify-content-center overflow-hidden rounded-2" style="width: 4.5rem; height: 4.5rem;">n' +
                    '<img id="' + imageId + '" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" style="height: 4.5rem;" alt="Destinationsbild" title="' + sh.title + '">n' +
                    '</div>n' +
                    '</div>n' +
                    '<div class="col text-muted ms-2 text-truncate">n' +
                    '<div class="line-clamp-3">n' + sh.text +
                    '</div>n' +
                    '</div>n' +
                    '</a>n' +
                    '</div></div></div>';

                containers.push(markup);
            }
        }
        if (containers.length === 0)
            return null;

        return containers.join('');
  },


    /**
     * renders markup for the placeholder container id="search-history-holderie" for the searchHistory
     * @return {string}
     */
    renderSearchHistoryHolderContainer() {
        let localData = JSON.parse(localStorage.getItem('searchHistoryData'));
        if (localData.length !== 0) {
            return '' +
                '<div class="container mt-4">' +
                '<div id="historyIndicator" class="h4 col-form-label w-100">Vergangene Suchanfragen</div>' +
                '<div class="row keen-slider keen-slider-dynamic" id="search-history-holder" data-slides="3" data-slides-xl="3" data-slides-lg="3" data-slides-md="3" data-slides-sm="2" data-slides-xs="1">' +
                '</div>';
        }
    }
$(document).on('click', '.searchHistoryDeleteButton', function () {

        let searchHistoryHolder = $('#search-history-holder');
        let optionen = searchHistoryHolder.data('keenSliderOptions');
        let navigation = searchHistoryHolder.data('keenSliderNavigation');
        let slide_index = $(this).parents(".keen-slider__slide").index('.keen-slider__slide');

        let localData = JSON.parse(localStorage.getItem('searchHistoryData'));
        localData.splice(slide_index, 1);
        localStorage.setItem('searchHistoryData', JSON.stringify(localData));
        searchHistory.renderSearchHistoryContainers(searchHistory.createSearchHistoryData(6));

        searchHistoryHolder.data('keenSliderObject').destroy();
        searchHistoryHolder.children().eq(slide_index).remove();
        var slider = new KeenSlider('#search-history-holder', optionen, [navigation]);
        searchHistoryHolder.data('keenSliderObject', slider);
        console.log('Der slider wurde neu erstellt.');

        if (localData.length === 0) {
        searchHistoryHolder.slideUp();
            $('#historyIndicator').remove();
        }

        $().showToast({
            text: 'Ihre vergangene Suchanfrage wurde gelöscht.',
            class: 'text-white bg-success',
            btnClass: 'btn-close-white'
        });
        return false;
    });

2:

$(document).ready(function() {
  var keenSliders = $(".keen-slider");
  keenSliders.each(function() {
    var keenCarousel = $(this),
      responsive = {},
      slides = keenCarousel.attr("data-slides"),
      slidesLg = keenCarousel.attr("data-slides-lg"),
      slidesMd = keenCarousel.attr("data-slides-md"),
      slidesSm = keenCarousel.attr("data-slides-sm"),
      slidesXs = keenCarousel.attr("data-slides-xs");
    if (slidesXs !== undefined) {
      if (slidesXs === '1') {
        slidesXs = 1.2;
        responsive["(max-width: 576px)"] = { slides: {origin: "center", perView: slidesXs, spacing: 0}};
      } else {
        responsive["(max-width: 576px)"] = { slides: {perView: slidesXs, spacing: 0}};
      }
    }
    if (slidesSm !== undefined) {
      if (slidesSm === '1') {
        slidesSm = 1.2;
        responsive["(min-width: 576px)"] = { slides: {origin: "center", perView: slidesSm, spacing: 0}};
      } else {
        responsive["(min-width: 576px)"] = { slides: {perView: slidesSm, spacing: 0}};
      }
    }
    if (slidesMd !== undefined) {
      if (slidesMd === '1') {
        slidesMd = 1.2;
        responsive["(min-width: 768px)"] = { slides: {origin: "center", perView: slidesMd, spacing: 0}};
      } else {
        responsive["(min-width: 768px)"] = { slides: {perView: slidesMd, spacing: 0}};
      }
    }
    if (slidesLg !== undefined) {
      responsive["(min-width: 1200px)"] = { slides: {perView: slidesLg, spacing: 0}};
    }
    if (slides !== undefined) {
      responsive["(min-width: 1400px)"] = { slides: {perView: slides, spacing: 0}};
    }

    // suche slides über selector
    let childSelector = '.keen-slider__slide';

    var options = {
      loop: true,
      mode: "free-snap",
      perView: 1.2,
      breakpoints: responsive,
      selector: childSelector
    };

    createKeenSlider(keenCarousel, options);
  });

  /**
   *
   * @param element
   * @param options
   */
  function createKeenSlider(element, options) {
    var slider = new KeenSlider(element[0], options, [navigation]);
    element.data('keenSliderObject', slider);
    element.data('keenSliderOptions', options);
    element.data('keenSliderNavigation', navigation);
  }
  function navigation(slider) {
    let wrapper, dots, arrowLeft, arrowRight;

    // Funktion zum aufrufen aller Markups
    function markup(remove) {
      let result = true;
      wrapperMarkup(remove);
      if(!dotMarkup(remove)) return;
      arrowMarkup(remove);
    }

    //Funktion zum Entfernen eines Elementes
    function removeElement(elment) {
      elment.parentNode.removeChild(elment);
    }
    function createDiv(className) {
      var div = document.createElement("div");
      var classNames = className.split(" ");
      classNames.forEach((name) => div.classList.add(name));
      return div;
    }

    // Funktion zum Erstellen des HTML-Markups für Pfeile
    function arrowMarkup(remove) {
      if (remove) {
        removeElement(arrowLeft);
        removeElement(arrowRight);
        return;
      }

      arrowLeft = createDiv("arrow arrow--left");
      arrowLeft.addEventListener("click", function() {
        var newIndex = parseInt(slider.track.details.abs) - parseInt(slider.options.slides.perView);
        slider.moveToIdx(newIndex, true);
      });

      arrowRight = createDiv("arrow arrow--right");
      arrowRight.addEventListener("click", function() {
        var newIndex = parseInt(slider.track.details.abs) + parseInt(slider.options.slides.perView);
        slider.moveToIdx(newIndex, true);
      });

      wrapper.appendChild(arrowLeft);
      wrapper.appendChild(arrowRight);
    }

    // Funktion zum Erstellen des HTML-Markups für Wrapper
    function wrapperMarkup(remove) {
      if (remove) {
        var parent = wrapper.parentNode;
        while (wrapper.firstChild)
          parent.insertBefore(wrapper.firstChild, wrapper);
        removeElement(wrapper);
        return;
      }
      wrapper = createDiv("navigation-wrapper");
      slider.container.parentNode.appendChild(wrapper);
      wrapper.appendChild(slider.container);
    }

    // Funktion zum Erstellen des HTML-Markups für Punkte (Dots)
    function dotMarkup(remove) {
      if (remove) {
        removeElement(dots);
        return true;
      }
      dots = createDiv("dots");

      if(slider.track.details == null){
        return false;
      }

      var numDots = Math.ceil(slider.track.details.slides.length / Math.floor(slider.options.slides.perView));

      // Erzeugung der Punkte (Dots) und Zuweisung der Klick-Handler
      for (var i = 0; i < numDots; i++) {
        var dot = createDiv("dot");
        dot.addEventListener(
          "click",
          (function (page) {
            return function () {
              // Berechnung des Zielindex basierend auf der gewählten Seite
              var targetIndex = page * Math.floor(slider.options.slides.perView);
              slider.moveToIdx(targetIndex);
            };
          })(i)
        );
        dots.appendChild(dot);
      }

      // Hinzufügen der Punkte (Dots) zum Wrapper-Element
      wrapper.appendChild(dots);
      return true;
    }

    // Funktion zum Aktualisieren der CSS-Klassen basierend auf dem aktuellen Slider-Status
    function updateClasses() {

      if(slider.track.details == null){
        document.getElementById("search-history-holder").classList.add("d-none");
        document.getElementById("historyIndicator").classList.add("d-none");
        return false;
      }

      var activePageIndex = Math.floor(slider.track.details.rel / Math.floor(slider.options.slides.perView));
      var dotArray = Array.from(dots.children);

      dotArray.forEach(function (dot, idx) {
        idx === Math.floor(activePageIndex)
          ? dot.classList.add("dot--active")
          : dot.classList.remove("dot--active");
      });
      return true;
    }

    // Event-Handler‚
    slider.on("created", () => {
      markup();
      updateClasses();
    });
    slider.on("optionsChanged", () => {
      markup(true);
      markup();
      updateClasses();
    });
    slider.on("slideChanged", () => {
      updateClasses();
    });
    slider.on("destroyed", () => {
      markup(true);
    });
  }
});

The requested module ‘/node_modules/.vite/deps/firebase_app.js?v=bdc3ec1e’ does not provide an export named ‘getApps’

Haven’t had an issue until all of a sudden today. I have not changed any firebase.js code or any firebase rules anytime recently that could cause such an error. I’m using Vue 3 with Vite. I’m currently on Firebase version 10.0.0 which is latest.

Error:

Uncaught SyntaxError: The requested module ‘/node_modules/.vite/deps/firebase_app.js?v=bdc3ec1e’ does not provide an export named ‘getApps’ (at firebase.js:1:471)

firebase.js

import { getApps, initializeApp } from "firebase/app";
import { getAuth, onAuthStateChanged, sendEmailVerification } from "firebase/auth";
const firebaseConfig = {
apiKey: import.meta.env.VITE_APP_API_KEY,
authDomain: import.meta.env.VITE_APP_AUTH_DOMAIN,
projectId: import.meta.env.VITE_APP_PROJECT_ID,
storageBucket: import.meta.env.VITE_APP_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_APP_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_APP_APP_ID,
measurementId: import.meta.env.VITE_APP_MEASUREMENT_ID
};
const apps = getApps()
const firebaseApp = !apps.length ? initializeApp(firebaseConfig) : apps[0]
const firebaseAuth = getAuth(firebaseApp)
const getCurrentUser = () => new Promise((resolve, reject) => {
const unsub = onAuthStateChanged(firebaseAuth, user => {
unsub()
resolve(user)
}, reject)
})
export const createUserWithEmailAndPassword = (email, password) => {
return firebaseAuth.createUserWithEmailAndPassword(email, password)
}
export const signInWithEmailAndPassword = (email, password) => {
return firebaseAuth.signInWithEmailAndPassword(email, password)
}
// send Email Verification to user after sign up
export const sendEmailVerificationToUser = () => {
return sendEmailVerification(firebaseAuth.currentUser)
}

// reauthenticateUser, updatePassword
export const reauthenticateUser = (password) => {
const user = firebaseAuth.currentUser
const cred = firebaseAuth.EmailAuthProvider.credential(user.email, password)
return user.reauthenticateWithCredential(cred)
}
export const updatePassword = (password) => {
return firebaseAuth.currentUser.updatePassword(password)
}
export { firebaseApp, firebaseAuth, getCurrentUser }

v-if – condition based on screen size

im trying to use v-if to render 2 buttons in different containers on page, depending on screen size
is there way how to change parent of items in @media or way how to use screen size in v-if condition?

i tried

<div v-if="window.innerWidth < 860">
<!-- Some code -->
</div>

but it throws me “TypeError: Cannot read properties of undefined (reading ‘innerWidth’)”

(when i use just media query, there appears bug with radio btns, when they needs 2 clicks to get :checked styles)
when i tried @media, in fact there was 4 buttons, that binded to 2 variables

<!-- button code -->
<label>
  <input type="radio" name="month-season" id="month" value="month" v-model="monthSeason">
  <null-button>
     <img src="../assets/green-smile.png" alt="#" id="month-icon">
     text
  </null-button>
</label>


<!-- null-button -->
<div class="parent">
  <div class="container">
    <slot></slot>
  </div>
<div>

<!-- styles for button -->
<style>
    .month-season {
        text-align: right;

        label {
            .container {
                color: rgba(45, 206, 137, 1);
                background: white;
                img {
                    margin: 0 4px 0 0;
                }
            }
            input:checked + .parent .container {
                background: rgba(45, 206, 137, 1);
                color: white;
                img {
                    filter: brightness(1000%);
                }
            }
            input {
                appearance: none;
            }
        }
    }
</style>

Error message wehen I use window.innerWidth
when using window.innerWidth

hi i use kendo upload to upload image how i can preview image when i upload it im using jquery


thats what i make in jave script
$(“#ImageUpload”).kendoUpload({

    async: {
        saveUrl: null
    },
    validation: {
        allowedExtensions: [".jpg", ".jpeg", ".png", ".jfif"],
        maxFileSize: 0
    },
    multiple: false,
    select: function (e) {
        var files = e.files;
        var file = files[0].rawFile;
        var fileReader = new FileReader();
        fileReader.onload = function (e) {
            var byteArray = new Uint8Array(e.target.result);
            var b64encoded = btoa(String.fromCharCode.apply(null, byteArray));
            var data = { ImageName: file.name, Image: b64encoded, ContentType: file.type };
            $("#image").val(JSON.stringify(data));
        }
        fileReader.readAsArrayBuffer(file);
    },
    remove: function (e) {
        $("#image").val("");
    }
});
thats what i have in razor page:

                            <div class="col-md-6">
                                <label class="fw-bold mb-1">Image</label>
                                <input id="ImageUpload" asp-for="ImageName" class="form-control form-control-sm" type="file" />
                                <input type="hidden" id="image" name="image" /> 
                            </div>

type here


[I want to preview image beside name](https://i.stack.imgur.com/NZnBa.png)

`i try code just make uplad to image withour preview it i wanna preview it

`

Unexpected commas in output using a 2d array

I used a class to class to organize everything I needed in this small project and made it require a 2d array to print out a field to the screen

class Field {
  constructor(fieldArr) {
    this.fieldArr = fieldArr;
  }
  get field() {
    return this.print(); 
  }
  print() {
    console.log(this.fieldArr.join("n")) // new line made after each array
  }
}

const myField = new Field([
    ["*", "░", "O"],
    ["░", "░", "░"],
    ["O", "░", "O"]
])
myField.print()

expected:

*░O
░░░
O░O

got:

*,░,O
░,░,░
O,░,O

In pure CSS or JS (Jquery) change style of a parent but only on hover of one specific sub child

I am using WordPress and Elementor to build a mega menu.

screenshot

As you can see on the attached screenshot, I would like to change the header border-bottom-left and right radius to 0 when I hover items on my menu who have sub items.

Below you will find a simplified modeling of the present code (there is a lot more div between each elements as I use a CMS).

<section class="header">
   <div class="logo">...</div>
   <div class="menu">...</div>
      <ul>
         <li class="menu-item">Item 1</li>
         <li class="menu-item">Item 2</li>
         <li class="menu-item">Item 3</li>
         <li class="menu-item has-children">Item 4</li>
            <ul>
                <li>
                    <div>Content of my submenu</div>
                </li>
            </ul>
      <ul>
   <div class="buttons">...</div>
</section>

What I would like is : when I hover the <li> with the class “has-children” to change the style of the parent <section> with the class “header”, in order to modify his border radius bottom left and right.

I would love any idea to help me doing it in pure CSS or with a bit of JS.

Thanks by advance !

How to attach headers on a payload during api post request in framework7

I am new in framework7, I am trying to send request to the api using fetch method, the api need authorization, The way I did it seems to be not recognised by Framework7, below is what I did:

               app.request
              .post("http://127.0.0.1:8000/api/sellEletricity/"+ phone_number, {
                meterNumber: meterNumber,
                transactionValue:transactionValue,
                headers: {
                  "Content-Type": "application/json",
                  "Authorization": token
              },
            }).then(function (res) {
              app.preloader.hide();
              var data = JSON.parse(res.data);
              console.log(data);

The error I getting says “user is not authorised” meaning the api didnt get the token provided inside the headers. any info regarding above mentioned error.

SSE with React and Express on the same machine

So, i have a web app with an ExpressJS backend and a React frontend. I am trying to use SSE to send messages from the server to the client.

router.get('/testSSE', async function(request, response)
{
    
    //const sessionID = sessionError(request.body.sessionID);
    response.writeHead(200, {
        "Connection": "keep-alive",
        "Cache-Control": "no-cache",
        "Content-Type": "text/event-stream",
        "Access-Control-Allow-Origin": "*",
      });
      let counter = 0;
      const interval = setInterval(() => {
        const chunk = JSON.stringify({chunk: counter++});
        response.write(`data: ${chunk}nn`);
      }, 100);
    
      response.on("close", () => {
        clearInterval(interval);
        response.end();
      });

});

If I connect to this using cURL or Postman, everything works and the messages keep coming.

On the React side, I have this code:

 componentDidMount() {
        const evtSource = new EventSource("/api/testSSE", {
          withCredentials: false,
        });
      
        evtSource.onopen = () => {
          console.log("SSE connection opened");
        };
      
        evtSource.onmessage = (event) => {
          console.log("Received SSE message:", event);
        };
      
        evtSource.onerror = (error) => {
          console.error("SSE error:", error);
        };
      }

which works if I use the full http://localhost:3000/api/testSSE URL, but that’s not useful for a web app as it will only work when viewing the page on the machine hosting Express.

So, in my package.json for React, I have this line:
"proxy": "http://localhost:3000"
that works for every fetch to Express endpoints except this one.

What happens when I try to use the proxy URL is that the React client doesn’t receive any message until I close the Express server, and then all the messages come at once.
So for whatever reason, the proxy is working but holding all the messages until I close the server.

Optimizing JavaScript Performance: Is There a Point of Diminishing Returns?

I’ve been working as a senior JavaScript developer for quite some time, and I’m always striving to write efficient and performant code. However, I often wonder if there’s a point of diminishing returns when it comes to optimizing JavaScript performance.

Specifically, I’m interested in understanding the trade-off between code readability/maintainability and performance gains. While it’s clear that certain optimizations, like reducing redundant calculations or minimizing DOM manipulations, can significantly improve performance, at what point does the effort invested in these optimizations become less valuable?

My concern is that excessive optimization could lead to complex and convoluted code, which can be difficult to understand and maintain in the long run. Therefore, it would be helpful to hear from experienced developers about their insights and best practices in finding the right balance between performance optimization and code maintainability.

What are some guidelines or indicators that suggest when further optimization may not be worth the effort? Are there any general principles to follow or specific scenarios where the trade-off between performance and code complexity becomes more apparent?

I appreciate any advice or experiences shared that can shed light on this topic. Thank you!

npm install for a forked library does not install it completely

I am working on a private node js project made using nest js. I am using the node-coap library which I have forked into my company’s github profile. I am installing it into the project using npm install /node-coap, but it installs it incompletely into my node_modules folder. As a result, my compilation is unsuccessful and I get this error:

2023-07-11 14:32:54 src/coap/coap.controller.ts:2:24 - error TS2307: Cannot find module 'coap' or its corresponding type declarations.

2023-07-11 14:32:54

2023-07-11 14:32:54 2 import { Server } from 'coap';

2023-07-11 14:32:54                          ~~~~~~

2023-07-11 14:32:54 

2023-07-11 14:32:54 src/coap/coap.module.ts:4:23 - error TS2307: Cannot find module 'coap' or its corresponding type declarations.

2023-07-11 14:32:54 

2023-07-11 14:32:54 4 import * as coap from 'coap';

2023-07-11 14:32:54                         ~~~~~~

This is what I see in my node modules (it has named itself coap):Installed coap module inside my node_modules folder, shows only some files from the many on github.

I can’t figure out how to install it properly, and this has become a huge blocker in my development tasks. Kindly assist!

I tried these solutions at this website and this website but to no avail. Finally, I tried adding a script of "prebuild":"npm run build" and it gives me this error when I install the forked node-c

npm ERR! path /home/User/Work/project/project-module/node_modules/coap
npm ERR! command failed
npm ERR! command sh -c npm run build
npm ERR! > [email protected] build
npm ERR! > tsc -b
npm ERR! 
npm ERR! error TS5083: Cannot read file '/home/User/Work/project/project-module/node_modules/coap/tsconfig.json'.

npm ERR! A complete log of this run can be found in: 2023-07-11T10_40_22_375Z-debug-0.log```


Change button color in Tailwind/TypeScript when button is Active

I have a Carousel Object which contains Buttons. These buttons represent the “Semester” content that is shown below (an image is provided below).

enter image description here

I want the “semester 1” button to be Dark Blue by default and when another button is clicked I want that button to Dark Blue.

At the moment I can achieve this when I add the following focus: class to the Button Component but since it’s a focus class it turn lightblue the moment I click somewhere else and the button “semseter 1” is not darkblue by default:

class="rounded-full w-64 dark:bg-blue-300 dark:hover:bg-blue-500 focus:bg-blue-500"

enter image description here

I tried adding an class="active:bg-blue-500" but it was unsuccessful.
Why doesn’t simply adding an active class won’t work and how can I make this work?

[email protected]: The engine “node” is incompatible with this module. Expected version “^14.15.0 || ^16.10.0 || >=18.0.0”. Got “12.22.12”

I’ve been receiving this error

error [email protected]: The engine "node" is incompatible with this module. Expected version "^14.15.0 || ^16.10.0 || >=18.0.0". Got "12.22.12"        
error Found incompatible module.

This expect library us used by the jest package. By viewing the node_modules folder the expect package version is 26.6.2 but the error is generated by 29.6.1 version. Although, this version 29.6.1 isn’t used anywhere in the project it is still generating this node version incompatible error. I cannot update the node version cause other dependencies in the project will get affected. How can I resolve this issue?

I tried running to check which version of expect is dependent to which dependency.

npm ls expect

The result was like this

yarn why v1.17.3
[1/4] Why do we have the module "expect"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "expect"
info Reasons this module exists
   - "workspace-aggregator-0ca060b9-5530-4147-845d-6bce9cd2005f" depends on it
   - Hoisted from "_project_#jest-snapshot#expect"
   - Hoisted from "_project_#jest-runtime#@jest#globals#expect"
   - Hoisted from "_project_#jest-config#jest-jasmine2#expect"
info Disk size without dependencies: "244KB"
info Disk size with unique dependencies: "1.55MB"
info Disk size with transitive dependencies: "7.34MB"
info Number of shared dependencies: 68
=> Found "jest-circus#[email protected]"
info Reasons this module exists
   - "_project_#jest-circus" depends on it
   - Hoisted from "_project_#jest-circus#jest-snapshot#expect"
   - Hoisted from "_project_#jest-circus#jest-runtime#@jest#globals#expect"
info Disk size without dependencies: "236KB"
info Disk size with unique dependencies: "1.45MB"
info Disk size with transitive dependencies: "7.32MB"
info Number of shared dependencies: 67
=> Found "jest#[email protected]"
info Reasons this module exists
   - "_project_#jest#@jest#core#jest-snapshot" depends on it
   - Hoisted from "_project_#jest#@jest#core#jest-snapshot#expect"
   - Hoisted from "_project_#jest#@jest#core#jest-runtime#@jest#globals#expect"
   - Hoisted from "_project_#jest#@jest#core#jest-config#jest-jasmine2#expect"
info Disk size without dependencies: "236KB"
info Disk size with unique dependencies: "1.45MB"
info Disk size with transitive dependencies: "7.32MB"
info Number of shared dependencies: 67
=> Found "jest-cli#[email protected]"
info Reasons this module exists
   - "_project_#jest#jest-cli#jest-config#jest-jasmine2" depends on it
   - Hoisted from "_project_#jest#jest-cli#jest-config#jest-jasmine2#expect"
   - Hoisted from "_project_#jest#jest-cli#@jest#core#jest-snapshot#expect"
   - Hoisted from "_project_#jest#jest-cli#@jest#core#jest-runtime#@jest#globals#expect"
info Disk size without dependencies: "236KB"
info Disk size with unique dependencies: "1.45MB"
info Disk size with transitive dependencies: "7.32MB"
info Number of shared dependencies: 67
Done in 1.74s.

How to include pure text to children iterable?

There is span that contains different tags and pure text. I need to get pure text in order to do replace some word to other and the same time save tags.

In case span.children, text is ignoring. Is there way to iterable such items?

console.log(document.querySelector('span').children)
<span>
  <p>Ignore text</p>
  target text 1
  <img src="https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196" />
  target text 2
</span>

I mean the next result:

<!-- From -->
<span>
    <p>Ignore text</p>
    target text 1
    <img src="https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196"/>
    target text 2
</span>

<!-- To -->
<span>
    <p>Ignore text</p>
    new text 1
    <img src="https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196"/>
    new text 2
</span>