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

fix(is-visible): do not error if window.Node does not exist #3168

Merged
merged 3 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ jobs:
- run: npm run build
- run: npm run test:locales

# Test virtual rules
test_virtual_rules:
<<: *defaults
<<: *unix_box
steps:
- checkout
- <<: *restore_dependency_cache_unix
- run: npm run build
- run: npm run test:virtual-rules

# Run the test suite for nightly builds.
test_nightly:
<<: *defaults
Expand Down Expand Up @@ -262,6 +272,9 @@ workflows:
- test_locales:
requires:
- test_unix
- test_virtual_rules:
requires:
- test_unix
- build_api_docs:
requires:
- test_unix
Expand All @@ -279,6 +292,7 @@ workflows:
- test_win
- test_examples
- test_locales
- test_virtual_rules
- build_api_docs
- test_rule_help_version
- test_node
Expand All @@ -293,6 +307,7 @@ workflows:
- test_unix
- test_examples
- test_locales
- test_virtual_rules
- build_api_docs
filters:
branches:
Expand All @@ -304,6 +319,7 @@ workflows:
- test_unix
- test_examples
- test_locales
- test_virtual_rules
- build_api_docs
- test_rule_help_version
- test_node
Expand Down
2 changes: 1 addition & 1 deletion lib/commons/dom/is-visible.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function isVisible(el, screenReader, recursed) {
el = vNode ? vNode.actualNode : el;

const cacheName = '_isVisible' + (screenReader ? 'ScreenReader' : '');
const { DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE } = window.Node;
const { DOCUMENT_NODE, DOCUMENT_FRAGMENT_NODE } = window.Node ?? {};
const nodeType = vNode ? vNode.props.nodeType : el.nodeType;
const nodeName = vNode ? vNode.props.nodeName : el.nodeName.toLowerCase();

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"test:act": "karma start test/act-mapping/karma.config.js",
"test:act:debug": "npm run test:act -- --no-single-run --browsers=Chrome",
"test:locales": "mocha test/test-locales.js",
"test:virtual-rules": "mocha test/test-virtual-rules.js",
"test:rule-help-version": "mocha test/test-rule-help-version.js",
"test:node": "mocha test/node/*.js",
"version": "echo \"use 'npm run release' to bump axe-core version\" && exit 1",
Expand Down
23 changes: 23 additions & 0 deletions test/test-virtual-rules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var path = require('path');
var assert = require('chai').assert;
var glob = require('glob');
var axe = require('../axe');

var files = glob.sync(path.join(__dirname, 'integration/virtual-rules/*.js'));

before(function() {
global.axe = axe;
global.assert = assert;
});

after(function() {
delete global.axe;
delete global.assert;
});

describe('virtual-rule node tests', function() {
files.forEach(function(file) {
// load the test file and run with global axe and assert now defined
require(file);
});
});