Lacking IE support. "matches" and "fetch" polyfill required.
While playing around with the v2 beta, I checked out IE support, where I got two errors regarding missing polyfills. After adding those, I didn't get any error in the console anymore, but the transition would hang right after the "leave before" hook (I made console logs for every hook to debug).
First error I encountered (matches method):
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector;
}
Second error (fetch):
Polyfills should be included and after adding them, the transition should work fluently.
Transition hangs at "leave before".
Open this example page (localhost) and check the IE console (Polyfills linked at the bottom of the HTML files):
ieissue.zip
Hi @josias-r,
Thanks for the report!
I will work on this issue this week-end.
Probably rolling back to a good old school xhr.
I will also fix the matches problem… :+1:
@thierrymichel It seems like the polyfills have been added, since I'm not getting any errors with the newest unpkg versions. But the transition will still not complete on IE (I'm not getting any console logs for any hook except all 3 appear hooks).
I need to press a link twice on IE and the second time will load the page without transition.
Ok. Sorry for that.
I will check directly into IE... 😱
@josias-r made a full check with my test repo on IE…
I've updated the "browser support/polyfill" section (Array.prototype.find was missing, also using default is easier).
Aside that, everything (transitions, views) is running fine.
Do you use some barba.js plugin ?
@thierrymichel Alright, I found the culprit. In addition to the console logs, I had a couple lines of code, to fetch and change the body classes / nav:
const html = d.next.html;
const parser = new DOMParser();
const newDoc = parser.parseFromString(html, "text/html");
const bodyClasses = newDoc.body.classList;
const oldNav = document.querySelector('nav');
const newNav = newDoc.querySelector('nav');
document.body.classList = bodyClasses;
document.querySelector('header').removeChild(oldNav);
document.querySelector('header').appendChild(newNav);
This works fine in any new Browser, any Idea what's wrong with the code for IE, or a way to write the code better? I'm guessing either the DOMParser doesn't work in IE or somehow IE was waiting for a pomise.
I had a strange issue with DOMParser on iOS. So I switched to simple document.createElement + innerHTML.
https://github.com/barbajs/barba/commit/8afe945e82de37b5f56760feb3a15f11dd3dd7e5
Thank you for the advice, I will try it out 🙏
Most helpful comment
Hi @josias-r,
Thanks for the report!
I will work on this issue this week-end.
Probably rolling back to a good old school
xhr.I will also fix the
matchesproblem… :+1: