axe icon indicating copy to clipboard operation
axe copied to clipboard

Axe just throws `Uncaught TypeError: can't access property "textCo...`

Open SyedM-dev opened this issue 3 years ago • 3 comments

Axe just throws the error :-

Uncaught TypeError: can't access property "textContent", document.head.getElementsByTagName(...)[0] is undefined

in firefox for no reason it seems that on line 532 in axe.js

else {
    axeStylesElement.textContent = document.head.getElementsByTagName('style')[0].textContent;
    initialiseStylesheets();
}

document.head.getElementsByTagName('style')[0] returns undefined?? I don't get where the issue is? Here's a screen shot Screenshot from 2022-02-19 11-13-55

Thanks in advance! Cheers!

SyedM-dev avatar Feb 19 '22 08:02 SyedM-dev

Hi @Toprun123,

Thanks for this heads up.

Re:

document.head.getElementsByTagName('style')[0] returns undefined

Hmmm. Without pulling up the code and going through it in detail, my first guess (in this case) is that...

... the axe script might be running before the DOM has finished rendering.

You can ensure that the axe script only loads after the DOM has finished rendering by including your reference to the axe script just before the closing </body> in your document.

Thanks.

RouninMedia avatar Feb 19 '22 09:02 RouninMedia

I would like to add that am also facing this issue and after putting it at the end, I am getting a different error Uncaught DOMException: Failed to execute 'insertRule' on 'CSSStyleSheet': Failed to parse the rule '.menu-item[data-locked="true"] ! .menu-item[data-locked="false"]{opacity:0.3; }'. at axeStyle (http://localhost/axe.js:582:29) at http://localhost/axe.js:469:44 at Array.forEach (<anonymous>) at initialiseStylesheets (http://localhost/axe.js:469:18) at XMLHttpRequest.<anonymous> (http://localhost/axe.js:499:59)

Mani-cwaf avatar Oct 29 '22 05:10 Mani-cwaf

Thanks for bringing this to my attention, @Mani-cwaf.

I'm not currently maintaining Axe (2016-17), though I aim to return to it - at some point - possibly as soon as I've completed several key next steps on my two main projects: Ashiva and Danis³h (2019-2022).

I want to return to Axe not least because I want to finish what I started in early 2017 with axeBlades.

axeBlades are essentially CSS presentational states (like :hover and :focus) but based on any type of User Interaction which can be detected by JavaScript EventListeners.

When I return to Axe to work on axeBlades, I will tidy up everything else and make it more robust and compatible with modern browsers.

Thanks again.

RouninMedia avatar Nov 04 '22 17:11 RouninMedia