From 7b46f63b2c05bee407b6e5f6b0c6c1579d06f011 Mon Sep 17 00:00:00 2001 From: Olivier Dehon <1093779+noead01@users.noreply.github.com> Date: Sat, 19 May 2018 13:03:08 -0400 Subject: [PATCH] fix(core): Define 'axe-core' as an AMD module (#859) * fix(core): Explicitly name the axe module 'axe-core' Avoid the "Mismatched anonymous define() modules" error when the axe script is injected in a page that uses requireJS Closes #849 * fix: Prevent color rules from crashing Chrome 66+ #856 (#861) * chore: Release axe-core 3.0.2 * chore: Enable Greenkeeper for managing dependencies (#847) * chore: add Greenkeeper config file * chore(package): update dependencies * chore(package): update dependencies * chore(package): update dependencies * chore(package): update dependencies * chore(package): update dependencies * chore(package): update dependencies * docs(readme): add Greenkeeper badge * chore: update to use babel-core * chore: update to latest uglify config properties `bracketize` became `braces` and `expect` became `reserved` * chore: add sri-history lifecycle hook to release (#844) * chore: disable growl to prevent errors in testing * chore: Rename Jest example to help greenkeeper (#871) * chore: rename jest example to help greenkeeper plus signs are invalid in filenames/directories Closes https://github.com/dequelabs/axe-core/issues/869 * chore: add config to jest_react example Closes https://github.com/dequelabs/axe-core/issues/865 * fix(core): Explicitly name the axe module 'axe-core' Avoid the "Mismatched anonymous define() modules" error when the axe script is injected in a page that uses requireJS Closes #849 * test(core): Validate that the axe module is named 'axe-core' Added integration test to check the value of the first argument to define() Closes #849 --- lib/core/index.js | 3 ++- test/integration/full/umd/umd-define.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/core/index.js b/lib/core/index.js index 2e021a3fa3..01bb3a80e8 100644 --- a/lib/core/index.js +++ b/lib/core/index.js @@ -6,7 +6,8 @@ var axe = axe || {}; axe.version = '<%= pkg.version %>'; if (typeof define === 'function' && define.amd) { - define([], function () { + // Explicitly naming the module to avoid mismatched anonymous define() modules when injected in a page + define('axe-core', [], function () { 'use strict'; return axe; }); diff --git a/test/integration/full/umd/umd-define.js b/test/integration/full/umd/umd-define.js index 39d77f3a4b..9c93d5ea9e 100644 --- a/test/integration/full/umd/umd-define.js +++ b/test/integration/full/umd/umd-define.js @@ -6,8 +6,15 @@ describe('UMD define', function () { assert.equal(defineCalls.length, 1); var call = defineCalls[0]; - assert.isFunction(call[1]); - assert.strictEqual(call[1](), axe); + assert.isFunction(call[2]); + assert.strictEqual(call[2](), axe); + }); + + it('defines module name as axe-core', function () { + assert.equal(defineCalls.length, 1); + + var call = defineCalls[0]; + assert.equal(call[0], 'axe-core'); }); });