PageSourceSearch

https://ch-auxerre.fr/libraries/popperjs/dist/esm/utils/validateModifiers.js

js ch-auxerre.fr collected 2026-10-06 11:15:05 UTC 3,261 bytes, 81 lines download raw bytes

vendor: 3,261 bytes, lines 1-81
1import format from "./format.js";
2import { modifierPhases } from "../enums.js";
3var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
4var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
5var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
6export default function validateModifiers(modifiers) {
7  modifiers.forEach(function (modifier) {
8    [].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
9    .filter(function (value, index, self) {
10      return self.indexOf(value) === index;
11    }).forEach(function (key) {
12      switch (key) {
13        case 'name':
14          if (typeof modifier.name !== 'string') {
15            console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
16          }
17
18          break;
19
20        case 'enabled':
21          if (typeof modifier.enabled !== 'boolean') {
22            console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
23          }
24
25          break;
26
27        case 'phase':
28          if (modifierPhases.indexOf(modifier.phase) < 0) {
29            console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
30          }
31
32          break;
33
34        case 'fn':
35          if (typeof modifier.fn !== 'function') {
36            console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
37          }
38
39          break;
40
41        case 'effect':
42          if (modifier.effect != null && typeof modifier.effect !== 'function') {
43            console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
44          }
45
46          break;
47
48        case 'requires':
49          if (modifier.requires != null && !Array.isArray(modifier.requires)) {
50            console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
51          }
52
53          break;
54
55        case 'requiresIfExists':
56          if (!Array.isArray(modifier.requiresIfExists)) {
57            console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
58          }
59
60          break;
61
62        case 'options':
63        case 'data':
64          break;
65
66        default:
67          console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
68            return "\"" + s + "\"";
69          }).join(', ') + "; but \"" + key + "\" was provided.");
70      }
71
72      modifier.requires && modifier.requires.forEach(function (requirement) {
73        if (modifiers.find(function (mod) {
74          return mod.name === requirement;
75        }) == null) {
76          console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
77        }
78      });
79    });
80  });
81}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.