How can I resolve the Chrome warning: The deferred DOM Node could not be resolved to a valid node

I’m running a node.js project on a localhost server, and I’ve been doing this for months without seeing this, but recently, I’ve been getting this warning when I open the inspector:

The deferred DOM Node could not be resolved to a valid node.

I usually go into the inspector on an element to check out some attribute, eventListener, or other info, but this warning is popping up and it doesn’t take me to the element. It’s been pretty annoying, and I don’t really know why it started showing up or how to get rid of it. My only clue is that I was changing some initialization settings for my express sessions around the same time this appeared, but I’m not sure that this is related.

Has anyone else run into this before? How do you get rid of the warning?
Thanks!

implement a memoization function in JavaScript

The function that I need to implement should take a function to memoize, then return a new function that remembers the inputs to the supplied function.

This is an exercise, for such is not required for the memoize function to remember all previous values, just the last input value, and the function return.

function memoizeTransform(f) {
  // valOne & valTwo intend to record the input values
  // of the function
  let valOne
  let valTwo
  // lastResult intend to record the result value of the function
  let lastResult
  const memoize = (funct) => (x1, x2) => {
    if (valOne === x1 && valTwo === x2) {
      console.log("if statement")
      return lastResult
    } else {
      lastResult = funct(x1, x2)
      return lastResult
    }
  }
  return memoize(f)
}

The actual code is not capable of accessing the previous values that I’m trying to record.

Getting Value of Multiple Selected Checkbox with Same Name in JavaScript

I can’t seem to get the correct output. I am not sure if my for loop is the problem. Please excuse my variable names. I know I know, I made them very obvious. 🙂 By the way, should I use var here or let is fine?

I have read somewhere that when declaring a variable:

var => function-scoped

ES6 (ES2015): let, const => block-scoped

The check all button won’t work as well.

Your input will be highly appreciated.

<html>
 <head>
  <title>Get Checkbox Value</title>
  <style type="text/css">
      body {
          padding-top: 10px;
          font-family: Verdana, Geneva, Tahoma, sans-serif;
          background-color: #ede5e5;
          height: 100vh;
      }
      div { 
          width: 50%;
          margin: auto;
          border: 1px solid lightgray;
          border-radius: 5px;
          -webkit-box-shadow: 0 1px 2px 0 rgb(34 36 38 / 15%);
          box-shadow: 0 1px 2px 0 rgb(34 36 38 / 15%);
          padding: 10px;
          padding-left: 20px;
          padding-bottom: 30px;
          background-color: white;
      }
      button {
          padding:5px;
          font-size: 16px;
          font-weight: bold;
      }
      label {
          font-size: 18px;
          font-weight: bold;
      }
      input [type=checkbox] {
          width: 20px;
          height: 20px;
      }

  </style>

 </head>
<body>
    <div style="">
      <h2>Select a Programming Language You Love</h2>
      <form id="frm-lang">
          
          <input type="checkbox" name="languages" value="JavaScript">
          <label>JavaScript</label><br/>

          <input type="checkbox" name="languages" value="PHP">
          <label>PHP</label><br/>

          <input type="checkbox" name="languages" value="Pyton">
          <label>Pyton</label><br/>

          <input type="checkbox" name="languages" value="C#">
          <label>C#</label><br/>

          <input type="checkbox" name="languages" value="C++">
          <label>C++</label><br/><br/>

          <button id="btnSubmit">Submit</button>
          <button id="btnCheckAll">Check All</button>


      </form>


    </div>
     <script>
         let formvar = document.getElementById('frm-lang');  
         let valuesvar = [];

         formvar.addEventListener('submit', function(e) {   
          e.preventDefault ();
          let checkboxesvar = document.getElementsByName('languages');
          for (let i = 0; i < checkboxesvar.length; i++) {  
              if (checkboxesvar[i].checked == true) {  
              
                  valuesvar.push(checkboxesvar[i].value);  
              }   
          }

           alert('The values(s): ' + valuesvar.toString());
         });   

         // for the check all button

         document.getElementById('btnCheckAll').onclick = function(e) {
             e.preventDefault();
             let checkboxesvar = document.getElementsByName('languages');
             for (let i=0; i < checkboxesvar.length; i++) {
                 checkbboxesvar[i].checked = true;
             }
         }


            
     </script>

</body>
</html>

Is it best to separate the dashboard to a new subdomain when your landing page is static generated using Next.js?

We already have multiple pages that are statically generated by Next.js using the command

next build && next export

and hosted on AWS S3

My question is if we need to build a dashboard with firebase authentication and a stripe subscription, should we create a new app and host it to a subdomain? probably using a create-react-app instead of next.js?

J5 – JavaScript can’t find variable “strokeCap”

I’m trying to get into generative Art and using for the first time p5.js for that. Now, I’ve tried to follow a guide to understand the process. I did exactly how the guide told me to do so, now I’m trying to figure out why I do have an error. The error is “ReferenceError: Can’t find variable: strokeCap” I’m not really sure, why it does say can’t find variable. Please help me out! I’d be very thankful.

function setup() {
  createCanvas(400, 400);
  noLoop()
  colorMode(HSL)
}

function draw() {
  background("antiquewhite");
}
 let loops = 5;
 while (loops--) {
    strokeCap(SQUARE);
  strokeWeight(random(50));
  stroke(random(0, 50), random(0, 100), random(0, 100));
  line(random(50,350),random(50,350),random(50,350),random(50,350));
}

function mousePressed(){
  saveCanvas("outputSave","png")
}

Vue.js validation form with vee-validate

i want to create custom rule and message for it, so i write

     defineRule("required", (value) => {
       if (value === "")
         {
         return `The ${field} is required`;
         }
             return true;
           });

i want to text something for the message, as you can see, i write field, but its not the way how it works, what should i write instead of

       ${field}

to see my inputs name?

Authorizaition problem with MTA project on Business Technology Plattform

we made a few Fiori apps(MTA), that we host on the BTP and will be used in the Launchpad Service. Because the customer doesn’t want to buy licenses and make SAP accounts for every Supplier that uses the apps, we used a technical user for the authorization in the destination. The Problem is that the displayed data is user specific and when we use a technical user we can’t read the BTP user in the SAP backend. We fixed this by reading the email address from the user through ushell and adding a custom header in the requests. Unfortunately the key figures on the Fiori Tiles are just static links to the odata service and we can’t send the user with it.

Destination

Is there a way to get the BTP user information to the SAP Backend for the tile number without giving every supplier an SAP user in the system?

Failed to resolve directive: scroll-to Vue-scollto

I am making a web application with Vue js(i am a newbie on vue js), specifically Vue 2.x. I want to click in an element of a menu, and then scroll to the that element. I have thought to use this tool https://vue-scrollto.netlify.app/examples/ as it is exactly what i want to do.

The problem is that when I repeat the same the code as in the examples, I receive the error “[Vue warn]: Failed to resolve directive: scroll-to“. Here is my code:

<div :class="{subelementos: isOpenAndroid}">
        <div class="subelementos2">
          <p v-scroll-to="'#prueba'" class="subelementos3" @click="menuClick('android')">Principios</p>

        </div>
</div>

And then in another component:

<div id="prueba">
      <p>TEXTEXT</p>
</div>

I don’t know if someone is familiar with this tool. I think i am missing something important.

PS: Maybe is a stupid question(sorry about that) but, do you think is mandatory to use Nuxtjs? On the official page of the tool it is mentioned, but I think is optional https://vue-scrollto.netlify.app/docs/#nuxt-js.

Trying to understand if I have a memory leak here, or am I just misinterpreting the heap inspector results?

I have a rather large code, and I wanted to see, if it performs correctly memory wise, using the Chrome Developer Tools, Memory tab. So I did a little digging there, and I am experiencing something really strange, which I don’t know how exactly to interpret.

Basically, what I realized, is that I have a class, named Animator, which is responsible to watch for animation end events, when the code is animating an object, via CSS. It can do various different things, but in it’s most basic form it is to watch and wait for animations to perform, in jQuery.

Here’s the whole class:

class Animator {
    protected settings: animatorOptions;
    protected watchers: watcherData[] = [];

    constructor(settings: animatorOptions) {
        this.settings = settings;

        if (this.settings.$watchers !== undefined) {
            for (const $watch of this.settings.$watchers) this.watch($watch);
        }
    }

    /** Add a new watch to the animator
     * 
     */
    watch(option: JQuery<HTMLElement> | watcherOption) {
        const $elemGroup: JQuery<HTMLElement> = utils.isjQuery(option) ? option : option.$watchedElem;

        $elemGroup.each((_index, element) => {
            const watchOption: watcherOption = jQuery.extend<any, watcherOption>(true, utils.isjQuery(option) ? {} : option, {
                $watchedElem: jQuery(element)
            });

            if (watchOption.animationEvents === undefined) watchOption.animationEvents = this.getWatchEventsForGroup(watchOption.animationGroup ?? this.settings.animationGroup);

            this.watchers.push(watchOption);
        });
        
        return this;
    }

    /** Initiate the animation. The function resolves to a boolean, indicating if the animation timed out or not. Meaning, that if this function resolves to "true", treat it as the animation timed out, if it resolves to "false", treat it as the animation is finished. This function will never reject.
     * 
     */
    async animate(initer?: () => void): Promise<boolean> {
        const promises: Promise<any>[] = [];
        for (const watch of this.watchers) {
            watch.Deferred = new Deferred();
            watch.animationEnderFunction = (evt) => {
                evt.stopPropagation();
                if (evt.target !== evt.currentTarget) return;

                watch.Deferred.resolve(true);
                if (watch.onAnimationEnd) watch.onAnimationEnd.apply(this, [evt]);
                watch.$watchedElem.off(watch.animationEvents, watch.animationEnderFunction);
            }

            watch.$watchedElem.on(watch.animationEvents, watch.animationEnderFunction);
            promises.push(watch.Deferred.promise);
        }

        return new Promise((resolve, reject) => {
            let isResolved: boolean = false;
            let timeout: any;

            const resolveSuccesfully = () => {
                if (!isResolved) resolve(false);
                isResolved = true;

                if (timeout !== undefined) clearTimeout(timeout);    
            }

            const resolveTimeout = () => {
                if (!isResolved) resolve(true);

                for (const watch of this.watchers) watch.$watchedElem.off(watch.animationEvents, watch.animationEnderFunction);
                isResolved = true;
            }
            
            if (initer) initer.apply(this, []);
            for (const watch of this.watchers) {
                if (watch.redraw) watch.$watchedElem.yellow().redraw();

                const animationGroupType = watch.animationGroup ?? this.settings.animationGroup;
                if (animationGroupType !== null && watch.safeMode !== undefined && watch.safeMode === true) {
                    const computedStyles = window.getComputedStyle(watch.$watchedElem[0]);
                    const autoResolve = (
                        (animationGroupType === 'animation' && ['0s', ''].includes(computedStyles.getPropertyValue('animation-duration'))) ||
                        (animationGroupType === 'transition' && ['0s', ''].includes(computedStyles.getPropertyValue('transition-duration')))
                    );

                    if (autoResolve) {
                        watch.$watchedElem.off(watch.animationEvents, watch.animationEnderFunction);
                        watch.Deferred.resolve(true);
                        if (watch.onAnimationEnd) watch.onAnimationEnd.apply(this, [true]);
                    }
                }
            }
            
            if (this.settings.timeout !== undefined) {
                timeout = setTimeout(() => {
                    resolveTimeout();
                }, this.settings.timeout);
            }

            Promise.all(promises).then(() => {
                resolveSuccesfully();
            });
        });
    }

    /** Get the list of event listeners for a specific watch group
     * 
     */
    private getWatchEventsForGroup(group: predefinedAnimationGroups): string {
        return group === 'animation' ? 'animationend webkitAnimationEnd oanimationend MSAnimationEnd mozAnimationEnd' : 'transitionend webkitTransitonEnd otransitionend MSTransitionEnd mozTransitionEnd';
    }
}

This class is usually used in my code, in the following way:

...
await new Animator({animationGroup: 'animation', $watchers: [$outScreen]}).animate(() => {
     $outScreen.addClass(animationEffect.outClass);
});

What I was expecting, that when I take a snapshot of my page, in Chrome DevTools, I should see no Animator class instances at all, because after the animation finishes, nothing is referencing the class anymore, and it should be garbage collected, but this is not the case. Each and every instantiation of this class appears in the snapshot taken with Chrome.

Here is my first question: does this indeed mean, that I have some kind of memory leak here, and the instantiated Animator classes, are not garbage collected, or I am misunderstanding the usage of the Memory tab in Chrome Dev Tools?

Continuing with the assumption, that these instances are indeed not garbage collected, I followed along, and checked the Retainers tab. If I am not mistaken, this should show me other variables or places in my code, which are still referencing a specific instance, and why it can’t be garbage collected at the moment, but what I found here, is even stranger (if my assumption about how retainers work is correct). Here’s a screenshot of what I am seeing in the dev tools:

Memory Snapshot

Based on what Chrome is showing me, there are still 10 instances of the Animator class, inside the memory, and what is holding them there, are themselves. The two retainers I see here, are pointing to the following lines of code:

// Animator.ts 80
watch.animationEnderFunction = (evt) => {
   evt.stopPropagation();
   if (evt.target !== evt.currentTarget) return;

   watch.Deferred.resolve(true);
   if (watch.onAnimationEnd) watch.onAnimationEnd.apply(this, [evt]);
   watch.$watchedElem.off(watch.animationEvents, watch.animationEnderFunction);
}

This is the closure, which should fire when an animation ends, and it is indeed referencing itself, but the other one, points to the for loop, two lines above this code. Why is my for loop, keeping the whole instance in the memory?

So, basically, there are many things to which I am looking for an answer on:

  1. Am I correct, that if I can find a variable, with a class instance in the Chrome Dev Tools Memory tab, it means that the respective instance was not garbage collected?
  2. When checking for the retainers of that variable, it should show me what other variables are still referencing this one, and thus why it was not garbage collected yet?
  3. How can a for loop prevent something from garbage collection?

get value span and set to variabel

I’m confused about how to take the span value and set the value into a variable, with the aim of this variable we want to sum. FYI, this is an example of using an application to see postage using rajaongkir

this is code

<script type="text/javascript">
    $('.pilih_ongkir').on('click',function(){

        var tarif = parseInt($(this).attr("tarif"));

        $('#ongkir').text('Rp. '+format_rupiah(tarif));
    
    });

    function format_rupiah(nominal){
        var  reverse = nominal.toString().split('').reverse().join(''),
             ribuan = reverse.match(/d{1,3}/g);
         return ribuan  = ribuan.join('.').split('').reverse().join('');
    }
</script>
<?php

    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => "https://pro.rajaongkir.com/api/cost",
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => "origin=".$asal."&originType=city&destination=".$id_kec."&destinationType=subdistrict&weight=".$berat."&courier=".$kurir."",
      CURLOPT_HTTPHEADER => array(
        "content-type: application/x-www-form-urlencoded",
        "key:The_key"
      ),
    ));
    $response = curl_exec($curl);
    $err = curl_error($curl);
    curl_close($curl);
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      $data = json_decode($response, true);
    }
    ?>
    <?php
     for ($k=0; $k < count($data['rajaongkir']['results']); $k++) {
    ?>
         <div title="<?php echo strtoupper($data['rajaongkir']['results'][$k]['name']);?>" style="padding:10px">
            
                 <?php
    
                 for ($l=0; $l < count($data['rajaongkir']['results'][$k]['costs']); $l++) {
                 ?>
                 <tr>
                     <td><?php echo $l+1;?></td>
                     <td>
                         <div style="font:bold 16px Arial"><?php echo $data['rajaongkir']['results'][$k]['costs'][$l]['service'];?></div>
                         <div style="font:normal 11px Arial"><?php echo $data['rajaongkir']['results'][$k]['costs'][$l]['description'];?></div>
                     </td>
                     <td align="center">&nbsp;<?php echo $data['rajaongkir']['results'][$k]['costs'][$l]['cost'][0]['etd'];?> hari</td>
                     <td align="right"><?php echo number_format($data['rajaongkir']['results'][$k]['costs'][$l]['cost'][0]['value']);?></td>
                     <td>
                    
                         <div class="radio">
                            <label><input type="radio" tarif="<?php echo $data['rajaongkir']['results'][$k]['costs'][$l]['cost'][0]['value']; ?>"   name="pilih_ongkir" class="pilih_ongkir" ></label>
                        </div>
                    </td>
                 </tr>
                 <?php
                 }
                 ?>
             </table>
         </div>
     <?php
    }
    ?>
    
<span id='ongkir'></span>

I want to set to a variable so that it can be sum or inputted to mysql.
I’ve tried using:

$data='<span id=”ongkir”></span>’;
echo $data;

But Failed, please help
thanks

Error: You must provide the json interface of the contract when instantiating a contract object, abi undefined

const HDWalletProvider = require('@truffle/hdwallet-provider');
const Web3 = require('web3');

const { abi, evm } = require('./compile');
console.log('abi',abi);

provider = new HDWalletProvider(
  'repeat place announce visit level double connect forest lens casual marble ladder',
  'https://mainnet.infura.io/v3/6f9868010c6948b2acd01733b944fcac'
);

const web3 = new Web3(provider);

const deploy = async () => {
  const accounts = await web3.eth.getAccounts();

  console.log('Attempting to deploy from account', accounts[0]);

  const result = await new web3.eth.Contract(abi)
    .deploy({ data: evm.bytecode.object})
    .send({ gas: '1000000', from: accounts[0] });

  console.log('Contract deployed to', result.options.address);
  provider.engine.stop();
};
deploy();

I created this code and I ran node deploy.js command and it’s gave me this error “Error: You must provide the json interface of the contract when instantiating a contract object.”

And it shows me abi undefined I didn’t understand me how to solve this error.

Aplicação php hospedada no heroku não reconhece meu arquivo main.js

Hospedei um site no heroku em que sua maior parte é PHP, na hora do deploy no heroku através do comando heroku buildpacks:set heroku/php defini que a aplicação era do tipo php, até então tudo correto e funcionando como deveria, CSS funcionando também, porém percebi que o servidor não está reconhecendo meu script JS (percebi observando que o meu btnShowPassword não estavam funcionando e os scripts para os inputs tbm não), estou precisando solucionar isso mas não sei como e não encontrei nada sobre na net. Segue abaixo o código do script no qual chama o arquivo main.js.

Getting ag-grid’s postSortRows to work with loadash’s sortBy

I’m suing ag-grid-vue to work with a dataset and would like to get the rows to be grouped by a certain value of field status using an array with the order I want. So, following the docs, inside the created() hook I’m using:

created() {
  this.postSortRows = (params) => {
    var rowNodes = params.nodes;

    const order = ['Atrasado', 'Pendente', 'Pronto', 'Entregue'];

    rowNodes = _.sortBy(rowNodes, function(obj) {
      return _.indexOf(order, obj.data.status);
    });
  //prints an empty array AND the the desired sorted array.
  console.log(rowNodes);

  }

But the problem with this is that the _.sortBy function is behaving asynchronously and if I try to console.log the value of rowNodes after the assignment, it prints two times:
enter image description here

I checked the lodash docs and it doesn’t say that the return value of the _.sortBy function is asynchronous, but it also does not say the opposite. I already tried to wrap the contents of the created hook inside another function and using a second argument as callback function, but it doesn’t work either. Is there anything special to get this working? Any help appreciated.