next-csrf
Version:
CSRF mitigation library for Next.js
32 lines (27 loc) • 857 B
JavaScript
(/* istanbul ignore next */ function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["module", "exports"], factory);
} else if (typeof exports !== "undefined") {
factory(module, exports);
} else {
var mod = {
exports: {}
};
factory(mod, mod.exports);
global.sortDomOrder = mod.exports;
}
})(this, function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function (elements) {
return elements.sort(compareDomPosition);
};
// sorts a list of elements according to their order in the DOM
function compareDomPosition(a, b) {
return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
}
module.exports = exports["default"];
});
//# sourceMappingURL=sort-dom-order.js.map