aem-guides-wknd
aem-guides-wknd copied to clipboard
Uncaught TypeError: Cannot read property 'hasAttribute' of null
Hi, I downloaded & installed the latest package & source code of WKND (0.0.4) on my local and after npm install on source code & running storybook I keep getting "Uncaught TypeError: Cannot read property 'hasAttribute' of null" error in console and accordion does not work for me.
Anyone else getting the same error?

Thanks, Kavin Mehta.
Hey Kavin,
What version of AEM, service packs (if any) are you using?
From: Kavin Mehta [email protected] Sent: Saturday, August 8, 2020 12:31:48 PM To: adobe/aem-guides-wknd [email protected] Cc: Subscribed [email protected] Subject: [adobe/aem-guides-wknd] Uncaught TypeError: Cannot read property 'hasAttribute' of null (#124)
Hi, I downloaded & installed the latest package & source code of WKND (0.0.4) on my local and after npm install on source code & running storybook I keep getting "Uncaught TypeError: Cannot read property 'hasAttribute' of null" error in console and accordion does not work for me.
Anyone else getting the same error?
[image]https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F142260%2F89718274-4f68f880-d972-11ea-9934-7cccf05c7e5d.png&data=02%7C01%7Cdgordon%40adobe.com%7C9a5e9e5a7b88415e0f7108d83bd1b203%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637325119101837732&sdata=rOCLxakpOiC38xkfsypZvnZ1x6dRfANVvppAGILrApA%3D&reserved=0 [image]https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F142260%2F89718292-5b54ba80-d972-11ea-936d-98933e19c445.png&data=02%7C01%7Cdgordon%40adobe.com%7C9a5e9e5a7b88415e0f7108d83bd1b203%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637325119101837732&sdata=a7lgu8es1OYSV8K5R65MVl3kqVgQ90j4lUtE68QM9Zs%3D&reserved=0
Thanks, Kavin Mehta.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fadobe%2Faem-guides-wknd%2Fissues%2F124&data=02%7C01%7Cdgordon%40adobe.com%7C9a5e9e5a7b88415e0f7108d83bd1b203%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637325119101847690&sdata=m%2B0BRG3z8kuUqbMLFCy7SgCvDWW8rGGITL8DbrUZ%2Fck%3D&reserved=0, or unsubscribehttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACEPBMTYGEOTSHXXOGCHD63R7WR2JANCNFSM4PYZSXWA&data=02%7C01%7Cdgordon%40adobe.com%7C9a5e9e5a7b88415e0f7108d83bd1b203%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637325119101847690&sdata=wIQBdAapOFN%2B9FU4ZS3IKNja4sr%2BYYh54UPy7pN05Yk%3D&reserved=0.
Sorry just rereading this. You are seeing this error when running storybook? It probably got introduced when the adobe data layer was added...
Hi,
I am running AEM 6.5.3 on Windows but yes it's because of adobe data layer. The accordion js script is looking for 'data-cmp-data-layer-enabled' in the body tag but Storybook doesn't have it so it fails. It looks like all core components that need JS to render are now looking for data-cmp-data-layer-enabled in body tag. I tried injecting it using preview-body.html in storybook but it didn't work. The core component js script needs to do some type of error handling maybe.
Thanks, Kavin Mehta.
Yeah I have had issues injecting external javascript using preview-body.html in storybook as well. Will have to investigate further. If you come up with something feel free to submit a PR
I am getting this error too. FWIW I don't think this error is to do with the Storybook or the presence of 'data-cmp-data-layer-enabled' but that the body is null when this code is executed. Seems like the code is in an IIFE and executing before DOM is ready.