adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
730 stars 736 forks source link

[Accordion] function `onDocumentReady` called before `DOMContentLoaded` #769

Closed Andrew-Cottrell closed 4 years ago

Andrew-Cottrell commented 4 years ago

https://github.com/adobe/aem-core-wcm-components/blob/core.wcm.components.reactor-2.7.0/content/src/content/jcr_root/apps/core/wcm/components/accordion/v1/accordion/clientlibs/site/js/accordion.js#L510

if (document.readyState !== "loading") {
    onDocumentReady();
} else {
    document.addEventListener("DOMContentLoaded", onDocumentReady());
}

When document.readyState === "loading" the onDocumentReady function is executed immediately, before the DOMContentLoaded event is fired. A reference to the onDocumentReady function should be passed to document.addEventListener, not the return value.

richardhand commented 4 years ago

Thanks very much @Andrew-Cottrell for spotting this!

richardhand commented 4 years ago

The code for this issue is merged to master and will be available in the upcoming 2.8.0 release.