Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check for window object #2

Closed
wants to merge 1 commit into from
Closed

Conversation

felixzapata
Copy link
Contributor

It checks the window object to avoid an undefined error when you use from a Node application.

@dylanb
Copy link
Contributor

dylanb commented Jun 12, 2015

Felix, can you explain the scenario under which you would use the library without a window object?

@felixzapata
Copy link
Contributor Author

I am trying to make a gulp plugin to use the axel core in a project instead of with the tests. This way you can check the rules meanwhile you are developing some templates.

If I use your library inside of my plugin (work in progress) when I launch my tests i have errors because the window object is not defined.

My gulp plugin should read the source files from a source and pass to your library.

Regards.

@dylanb
Copy link
Contributor

dylanb commented Jun 12, 2015

The way the rules engine works is it evaluates the HTML code using the DOM APIs. None of the rules will work if there is no DOM. If there is a DOM, it must have CSS enabled for certain of the rules to work, I think what you are trying to do is not within the scope of what this library was designed to do.

@felixzapata
Copy link
Contributor Author

I try to load the source file and parse it as a DOM to pass to your function. This way I think is more easy to use during the development instead to configure the test.

@dylanb
Copy link
Contributor

dylanb commented Jun 13, 2015

@felixzapata Instead of making this change, users who are doing what you are doing should add the following to their code base prior to calling the axe-core library

global.window = {};
global.window.addEventListener = function () {};

Then add the following to the end of the axe.js or the axe.min.js file

if (typeof module !== 'undefined') {
    module.exports = this.axe;
}

Now you can require it as follows:

var axe = require('./node_modules/axe-core/axe.js');

Note: the code was not intended to be run outside a browser, so we cannot guarantee the accuracy of the results if used this way.

@dylanb dylanb closed this Jun 13, 2015
@felixzapata
Copy link
Contributor Author

Well, thanks.. I will try to make some attempt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants