{"record":{"id":"81f29a2e9f97e1c1","repo":"ankane/pghero","slug":"nouislider-cssclasses-must-be-an-object","errorCode":null,"errorMessage":"noUiSlider: 'cssClasses' must be an object.","messagePattern":"noUiSlider: 'cssClasses' must be an object\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/assets/javascripts/pghero/nouislider.js","lineNumber":803,"sourceCode":"    function testKeyboardSupport(parsed, entry) {\n        if (typeof entry !== \"boolean\") {\n            throw new Error(\"noUiSlider: 'keyboardSupport' option must be a boolean.\");\n        }\n        parsed.keyboardSupport = entry;\n    }\n    function testDocumentElement(parsed, entry) {\n        // This is an advanced option. Passed values are used without validation.\n        parsed.documentElement = entry;\n    }\n    function testCssPrefix(parsed, entry) {\n        if (typeof entry !== \"string\" && entry !== false) {\n            throw new Error(\"noUiSlider: 'cssPrefix' must be a string or `false`.\");\n        }\n        parsed.cssPrefix = entry;\n    }\n    function testCssClasses(parsed, entry) {\n        if (typeof entry !== \"object\") {\n            throw new Error(\"noUiSlider: 'cssClasses' must be an object.\");\n        }\n        if (typeof parsed.cssPrefix === \"string\") {\n            parsed.cssClasses = {};\n            Object.keys(entry).forEach(function (key) {\n                parsed.cssClasses[key] = parsed.cssPrefix + entry[key];\n            });\n        }\n        else {\n            parsed.cssClasses = entry;\n        }\n    }\n    // Test all developer settings and parse to assumption-safe values.\n    function testOptions(options) {\n        // To prove a fix for #537, freeze options here.\n        // If the object is modified, an error will be thrown.\n        // Object.freeze(options);\n        var parsed = {\n            margin: null,","sourceCodeStart":785,"sourceCodeEnd":821,"githubUrl":"https://github.com/ankane/pghero/blob/7edb57986ffd36f9d64f0830c4ccc90a5eac46d6/app/assets/javascripts/pghero/nouislider.js#L785-L821","documentation":"noUiSlider (vendored at app/assets/javascripts/pghero/nouislider.js) validates every option passed to create(). testCssClasses requires the cssClasses option to be a plain object mapping internal class keys (target, origin, handle, ...) to CSS class names. Anything else - a string, a number, null - throws this Error during initialization, before the slider is built.","triggerScenarios":"Calling noUiSlider.create(el, {cssClasses: \"custom\"}) or {cssClasses: null}. Note that PgHero itself never customizes cssClasses, so this only fires in application code that extends the vendored slider's options, or when options objects are merged from an external source that supplies a non-object cssClasses value.","commonSituations":"Developers assume cssClasses takes a string like cssPrefix does; option objects built dynamically (e.g. JSON config) where cssClasses is a string or missing-typed; copying examples from a different noUiSlider major version whose option shapes changed.","solutions":["Pass an object: cssClasses: {target: \"my-target\", origin: \"my-origin\"} using the documented internal key names","If you only want a prefix on all generated classes, use cssPrefix: \"my-\" (string) instead of cssClasses","For a global change across all sliders, modify the exported nouislider.cssClasses default instead of per-create options"],"exampleFix":"// before\nnoUiSlider.create(el, { cssClasses: \"slider\" });\n\n// after - object mapping internal keys to class names\nnoUiSlider.create(el, { cssClasses: { target: \"slider\" } });","handlingStrategy":"type-guard","validationCode":"const cssClasses = options.cssClasses;\nif (cssClasses !== undefined && (typeof cssClasses !== \"object\" || cssClasses === null)) {\n  console.warn(\"cssClasses must be an object; ignoring\");\n  delete options.cssClasses;\n}\nnoUiSlider.create(el, options);","typeGuard":"function isValidCssClasses(v) {\n  return v === undefined || (typeof v === \"object\" && v !== null && !Array.isArray(v) && Object.values(v).every(x => typeof x === \"string\"));\n}","tryCatchPattern":null,"preventionTips":["Use cssPrefix (string) for a simple prefix; use cssClasses only with the documented object shape","Type-check option objects coming from JSON config before passing them to create()"],"tags":["nouislider","options","validation","javascript"],"backgroundTag":"library-option-validation","analyzedSha":"7edb57986ffd36f9d64f0830c4ccc90a5eac46d6","analyzedAt":"2026-08-21T17:33:54.942Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}