ember-a11y / ember-a11y-testing

A suite of accessibility tests that can be run within the Ember testing framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot modify dependent keys for `violationClasses` on `component-name` after it has been destroyed

ondrejsevcik opened this issue · comments

Hi, first of all, thanks for this awesome addon, it makes my life much better :)

I've installed this addon in my app (Ember 2.16) and when I'm browsing through pages, I got a lot of these errors into the console.

"Assertion Failed: Cannot modify dependent keys for `violationClasses` on `component-name` after it has been destroyed."

I know what it says in general, but I'm more curious why is this happening. Is it because I'm navigating too fast? Or is it some other issue?

Thank you,
Ondrej

I'm not 100% positive, but I believe this is because we run the audit asynchronously each time Ember's render-cycle is complete. See this line:

scheduleOnce('afterRender', this, 'audit');

So, I think what is happening is that we schedule a check for the component when you navigate, but the component is then destroyed before we actually run the audit. Thus, when the audit is run, you get the error in question.

Yeah, that's probably it. I've tried to put a debugger in there and it crashed accessing this property when this.get('isDestroyed') was true. So I guess there is missing check if the component is destroyed already.

Would you mind opening a PR to add the necessary check? It would be much appreciated!

I'm running into this error as well, and this definitely looks like the problem. But, I wanted to pose the question about if this event even needs scheduled at all. didRender is already called after render, couldn't it just directly invoke audit? If so, you'll want to look up everything needed from the component before calling axe.a11yCheck so that you do not run into similar errors from the callback passed to this function.

@trentmwillis I see an open PR is up: #92. Would it be possible to get a patch release out for this?

Yeah, I'm trying to get travis happy (and upgrade the addon) in my branch. But right now I'm seeing test failures. Hopefully I can get it fixed up tonight.

This was closed with c8ee8d0

I'll cut a release once CI passes :)