arvgta / ajaxify

Ajaxify - An Ajax Plugin
https://4nf.org/
275 stars 124 forks source link

Nuisance with "undefined elements" when clearing the cache(s) (plain vanilla version) #224

Closed arvgta closed 2 years ago

arvgta commented 2 years ago

A nuisance has been reported by our partner AllMediaLab in the plain vanilla version:

AllMediaLab has reported, that the nuisance happens only in the context of alwayshints and can be worked around by placing the respective link on each and every page of the site, which is obviously not the spirit of delta-loading.

This issue has also been reported by Sagar... (Sagar reported, that the bug seems to be within the addAll class)


You can also reproduce the issue on http://www.oeko-fakt.de/ :

  1. Clear the browser caches
  2. From the homepage traverse to "Produkte"
  3. Examine the error in the console, which should be similar to the following:
Uncaught TypeError: Cannot read properties of undefined (reading 'oApi')
    at produktsuche.js:4:22
    at produktsuche.js:44:6

Salient code:

$this.forEach(function(s) { //Iterate through selection
            var $t = s;
            url = $t.getAttribute(PK);
            if(_classAlways($t)) { //Class always handling
                _removeScript(); //remove from DOM
                _iScript($t); //insert back single external script in the head
                return; //this return may be dodgy, as the URL does not get pushed to the array as below?
            }
            if(url) { //URL?
                if(!$scriptsO.some(e => e == url)) { // Test, whether new
                    $scriptsO.push(url); //If yes: Push to old array
                    _iScript($t);
                }
                //Otherwise nothing to do
                return;
            }

            if(PK != "href" && !$t.classList.contains("no-ajaxy")) Ay.scripts($t); //Inline JS script? -> inject into DOM
        });

arvgta commented 2 years ago

Closing for the moment because there are lots of other open issues...