Skip to content

Commit

Permalink
Merge pull request #74 from browserstack/AXE-342-legal-complaint-chan…
Browse files Browse the repository at this point in the history
…ges-for-dom-forge-core

feat: adding custom stub
  • Loading branch information
SuyashSonawane authored Aug 1, 2024
2 parents 67dbf90 + 10bd5a0 commit b004343
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 18 deletions.
8 changes: 5 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = function (grunt) {
grunt.loadTasks('build/tasks');

var langs;
var wrapper = !!grunt.option('wrapper');
if (grunt.option('lang')) {
langs = (grunt.option('lang') || '').split(/[,;]/g).map(function (lang) {
lang = lang.trim();
Expand Down Expand Up @@ -85,11 +86,11 @@ module.exports = function (grunt) {
files: langs.map(function (lang, i) {
return {
src: [
'lib/intro.stub',
wrapper ? 'lib/custom/intro.stub' : 'lib/intro.stub',
'<%= concat.engine.coreFiles %>',
// include rules / checks / commons
'<%= configure.rules.files[' + i + '].dest.auto %>',
'lib/outro.stub'
wrapper ? 'lib/custom/outro.stub' : 'lib/outro.stub'
],
dest: 'axe' + lang + '.js'
};
Expand Down Expand Up @@ -127,7 +128,8 @@ module.exports = function (grunt) {
entry: 'lib/commons/aria/index.js',
destFile: 'doc/aria-supported.md',
options: {
langs: langs
langs: langs,
wrapper: wrapper
},
listType: 'unsupported' // Possible values for listType: 'supported', 'unsupported', 'all'
}
Expand Down
3 changes: 2 additions & 1 deletion build/tasks/aria-supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = function (grunt) {
* hence cannot be required at the top of the file.
*/
const done = this.async();
const { langs } = this.options();
const { langs, wrapper } = this.options();
if (wrapper) return true;
const fileNameSuffix = langs && langs.length > 0 ? `${langs[0]}` : '';
const axe = require(`../../axe${fileNameSuffix}`);
const listType = this.data.listType.toLowerCase();
Expand Down
15 changes: 15 additions & 0 deletions lib/custom/intro.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*! axe v<%= pkg.version %>
* Copyright (c) 2015 - <%= grunt.template.today("yyyy") %> Deque Systems, Inc.
*
* Your use of this Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This entire copyright notice must appear in every copy of this file you
* distribute or in any file that contains substantial portions of this source
* code.
*/
const createAxe = () => (function axeFunction (window) {
// A window reference is required to access the axe object in a "global".
var global = window;
var document = window.document;
2 changes: 2 additions & 0 deletions lib/custom/outro.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

}( typeof window === 'object' ? window : this ));
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"develop": "grunt dev --force",
"api-docs": "jsdoc --configure .jsdoc.json",
"build": "grunt",
"build:wrapper": "grunt --wrapper=true",
"eslint": "eslint --color --format stylish '{lib,test,build,doc}/**/*.js' 'Gruntfile.js'",
"test": "npm run test:tsc && run-s \"test:unit:* -- {@}\" --",
"test:tsc": "tsc",
Expand Down

0 comments on commit b004343

Please sign in to comment.