UNPKG

axe-core

Version:

Accessibility engine for automated Web UI testing

24 lines (18 loc) 502 B
/** * Array#sort callback to sort nodes by DOM order * @private * @param {Node} a * @param {Node} b * @return {Integer} @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Sort */ axe.utils.nodeSorter = function nodeSorter(a, b) { /*eslint no-bitwise: 0 */ 'use strict'; if (a.actualNode === b.actualNode) { return 0; } if (a.actualNode.compareDocumentPosition(b.actualNode) & 4) { // a before b return -1; } return 1; // b before a };