internet-programming/lab2/node_modules/bootstrap/js/dist/dom/data.js

64 lines
2.1 KiB
JavaScript
Raw Normal View History

2023-10-23 13:48:44 +04:00
/*!
2023-11-02 21:33:55 +04:00
* Bootstrap data.js v5.3.2 (https://getbootstrap.com/)
* Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
2023-10-23 13:48:44 +04:00
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Data = factory());
})(this, (function () { 'use strict';
/**
* --------------------------------------------------------------------------
2023-11-02 21:33:55 +04:00
* Bootstrap dom/data.js
2023-10-23 13:48:44 +04:00
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* Constants
*/
2023-11-02 21:33:55 +04:00
2023-10-23 13:48:44 +04:00
const elementMap = new Map();
const data = {
set(element, key, instance) {
if (!elementMap.has(element)) {
elementMap.set(element, new Map());
}
2023-11-02 21:33:55 +04:00
const instanceMap = elementMap.get(element);
2023-10-23 13:48:44 +04:00
2023-11-02 21:33:55 +04:00
// make it clear we only want one instance per element
2023-10-23 13:48:44 +04:00
// can be removed later when multiple key/instances are fine to be used
if (!instanceMap.has(key) && instanceMap.size !== 0) {
// eslint-disable-next-line no-console
console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`);
return;
}
instanceMap.set(key, instance);
},
get(element, key) {
if (elementMap.has(element)) {
return elementMap.get(element).get(key) || null;
}
return null;
},
remove(element, key) {
if (!elementMap.has(element)) {
return;
}
const instanceMap = elementMap.get(element);
2023-11-02 21:33:55 +04:00
instanceMap.delete(key);
2023-10-23 13:48:44 +04:00
2023-11-02 21:33:55 +04:00
// free up element references if there are no instances left for an element
2023-10-23 13:48:44 +04:00
if (instanceMap.size === 0) {
elementMap.delete(element);
}
}
};
return data;
}));
//# sourceMappingURL=data.js.map