Skip to content

Commit

Permalink
fix(heading-order): handle iframe as first result (#2876)
Browse files Browse the repository at this point in the history
  • Loading branch information
straker committed Apr 16, 2021
1 parent dc526d8 commit 33428d8
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/checks/navigation/heading-order-after.js
Expand Up @@ -34,10 +34,11 @@ function headingOrderAfter(results) {

// start by replacing all array ancestry paths with a flat string
// path
let headingOrder = results[0].data.headingOrder.map(heading => {
const pageResult = results.find(result => !result.node._fromFrame);
let headingOrder = pageResult.data.headingOrder.map(heading => {
return {
...heading,
ancestry: getFramePath(results[0].node.ancestry, heading.ancestry)
ancestry: getFramePath(pageResult.node.ancestry, heading.ancestry)
};
});

Expand Down
53 changes: 53 additions & 0 deletions test/checks/navigation/heading-order.js
Expand Up @@ -522,5 +522,58 @@ describe('heading-order', function() {
checks['heading-order'].after(results);
});
});

it('should not error if iframe is first result', function() {
var results = [
{
data: {
headingOrder: [
{
ancestry: 'path2',
level: 1
}
]
},
node: {
_fromFrame: true,
ancestry: ['iframe', 'path2']
},
result: true
},
{
data: {
headingOrder: [
{
ancestry: 'iframe',
level: -1
},
{
ancestry: 'path1',
level: 2
},
{
ancestry: 'path3',
level: 3
}
]
},
node: {
_fromFrame: false,
ancestry: ['path1']
},
result: true
},
{
node: {
_fromFrame: false,
ancestry: ['path3']
},
result: true
}
];
var afterResults = checks['heading-order'].after(results);
assert.isTrue(afterResults[1].result);
assert.isTrue(afterResults[2].result);
});
});
});

0 comments on commit 33428d8

Please sign in to comment.