Skip to content

Commit

Permalink
fix: colorio.js patch mocking CSS (#4456)
Browse files Browse the repository at this point in the history
Adds `patch-package` as suggested in the issue this PR fixes. The goal
is to allow `window.CSS` to be mocked `null` in situations such as using
JSdom.

Tests cover a version that is patched and one that is unpatched to
demonstrate the patch truly fixes the issue.

fixes: #4400

---

**Developer Notes/Questions** for review:

- Someone mentioned the patch step should _not_ be `postinstall`, what
should it be instead?
- For test coverage purposes it's useful to keep an unpatched version,
currently this is done manually in `patches/color.unpatched.js` but
perhaps there's a better way
- It's a bit gross modifying so many pre-compiled `dist` files
- Instead of a patch, we could pull in colorjs.io as a submodule and
build it ourselves, unsure how to propagate that to consumers of
axe-core however
- Perhaps this is fine and I could document how to update the patch in
the future

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com>
Co-authored-by: gaiety-deque <gaiety-deque@users.noreply.github.com>
  • Loading branch information
4 people authored Jun 13, 2024
1 parent 23b43dc commit 3ef9353
Show file tree
Hide file tree
Showing 10 changed files with 705 additions and 41 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ jobs:
paths:
- node_modules

# Build and cache axe.js
# Build and cache built files
build_unix:
<<: *defaults
<<: *unix_box
steps:
- checkout
- <<: *restore_dependency_cache_unix
- run: npm run prepare
- run: npm run build
- save_cache:
key: v9-cache-build-<< pipeline.git.revision >>
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
node-version: 20
cache: 'npm'
- run: npm ci
- run: npm run prepare
- run: npm run build
- uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ typings/axe-core/axe-core-tests.js

# doc
doc/rule-descriptions.*.md

1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ module.exports = [
ignores: [
'**/node_modules/*',
'**/tmp/*',
'patches/*',
'build/tasks/aria-supported.js',
'doc/api/*',
'doc/examples/jest_react/*.js',
Expand Down
Loading

1 comment on commit 3ef9353

@ahmad99wadi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tanx

Please sign in to comment.