moodle/lib/amd/build/normalise.min.js
Ferran Recio ff5f669cf8 MDL-76432 aria: add getFirst to nomalise
Half of the times the normalise module is used is to get a single
element. However, because jQuery elements can contain multiple elements
the getList is always an array. Due to this in many ocasions we repeat
the getList(VAR)[0] line instead of having a more readable getFirst
method which only implies a couple of lines in the original code.
2023-02-06 12:58:43 +01:00

10 lines
750 B
JavaScript

define("core/normalise",["exports","jquery"],(function(_exports,_jquery){var obj;
/**
* Normalisation helpers.
*
* @module core/normalise
* @copyright 2020 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.getList=_exports.getFirst=void 0,_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj};const getList=nodes=>nodes instanceof HTMLElement?[nodes]:nodes instanceof Array?nodes:nodes instanceof NodeList?Array.from(nodes):nodes instanceof _jquery.default?nodes.get():Array.from(nodes);_exports.getList=getList;_exports.getFirst=nodes=>getList(nodes)[0]}));
//# sourceMappingURL=normalise.min.js.map