Skip to content

Commit

Permalink
feat(index.js): change how to call to axe-core
Browse files Browse the repository at this point in the history
  • Loading branch information
felixzapata committed Aug 7, 2016
1 parent 4358b84 commit e5bb532
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ var gutil = require('gulp-util');
var vm = require('vm');
var fs = require('fs');
var through = require('through2');
var cheerio = require("cheerio");
var cheerio = require('cheerio');
var DOMParser = require('xmldom').DOMParser;
var context;
//var axe = require(__dirname + '/node_modules/axe-core/axe.min.js');
var axe = require('axe-core');

vm.runInThisContext(fs.readFileSync(__dirname + '/node_modules/axe-core/axe.js'));
//vm.runInThisContext(fs.readFileSync(__dirname + '/node_modules/axe-core/axe.js'));

//vm.runInThisContext(axe);

module.exports = function (options) {
/*if (!options.foo) {
Expand All @@ -29,9 +32,19 @@ module.exports = function (options) {
try {

//context = cheerio.load(file.contents.toString());
//context = file.contents.toString();
context = new DOMParser().parseFromString(file.contents.toString(), 'text/html');
file.contents = new Buffer(axe.a11yCheck(context.firstChild, options));
this.push(file);

//file.contents = new Buffer(axe.a11yCheck(context.firstChild, options));
//this.push(file);

//console.log(context.documentElement.attributes['0'].ownerDocument)

//console.log(context);

axe.a11yCheck(context, null, function(result) {
console.log(result);
});

} catch (err) {
this.emit('error', new gutil.PluginError('gulp-axe-core', err));
Expand Down

0 comments on commit e5bb532

Please sign in to comment.