{"record":{"id":"882e4d525c65e3f2","repo":"jeessy2/ddns-go","slug":"unknown-trigger-trigger","errorCode":null,"errorMessage":"Unknown trigger: ${trigger}","messagePattern":"Unknown trigger: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"static/tooltips.js","lineNumber":154,"sourceCode":"          this.$element.addEventListener('mouseleave', _leave);\n          break;\n        case 'focus':\n          this.$element.addEventListener('focusin', _enter);\n          this.$element.addEventListener('focusout', _leave);\n          break;\n        case 'click':\n          this.$element.addEventListener('click', () => {\n            if (this.$tooltip) {\n              this.hide();\n            } else {\n              this.show();\n            }\n          });\n          break;\n        case 'manual':\n          break;\n        default:\n          console.warn(`Unknown trigger: ${trigger}`);\n      }\n    });\n  }\n}\n\n// 初始化所有带data-tooltip属性的元素\nconst initTooltips = () => {\n  window.tooltips = {};\n  document.querySelectorAll('[data-toggle=\"tooltip\"]').forEach(element => {\n    let key = element.dataset.tooltipKey || element.id;\n    if (!key) {\n      key = crypto.randomUUID();\n      element.dataset.tooltipKey = key;\n    }\n    window.tooltips[key] = new Tooltip(element);\n  });\n};\n","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/jeessy2/ddns-go/blob/5874c2e6667c69357ab95079421131104bd3fcae/static/tooltips.js#L136-L172","documentation":"Tooltip._bindEvents switches on the configured trigger to attach show/hide listeners ('manual' is a no-op); any trigger value outside the supported set hits the default branch and logs this console.warn. The tooltip is still constructed but its trigger behavior is undefined/never bound.","triggerScenarios":"new Tooltip(el, { trigger: 'something' }) or data-trigger=\"something\" where the value is not one of the handled cases (e.g. hover/click/focus/manual as implemented); often a typo like 'hovr' or a copied option name from another tooltip library.","commonSituations":"Typo in the trigger option; migrating from another library whose trigger names differ; passing user/config-provided trigger strings without validation.","solutions":["Correct the trigger option to one of the supported values handled by _bindEvents's switch cases.","Validate the trigger value in the constructor and throw/throw early with the list of allowed values instead of only warning.","Check library docs/migration guide if the trigger names changed between versions.","Whitelist the trigger when it comes from configuration or markup before constructing the tooltip."],"exampleFix":"// before\nnew Tooltip(el, { trigger: 'hover' }); // if only click/focus/manual supported\n// after\nnew Tooltip(el, { trigger: 'click' }); // or the correct supported value","handlingStrategy":"validation","validationCode":"const SUPPORTED_TRIGGERS = ['hover', 'click', 'focus', 'manual'];\nfunction isValidTrigger(trigger) {\n  return SUPPORTED_TRIGGERS.includes(trigger);\n}\nif (!isValidTrigger(opts.trigger)) {\n  throw new Error(`trigger must be one of ${SUPPORTED_TRIGGERS.join(', ')}, got: ${opts.trigger}`);\n}","typeGuard":"function isValidTrigger(t) {\n  return ['hover', 'click', 'focus', 'manual'].includes(t);\n}","tryCatchPattern":null,"preventionTips":["Use constants/enums for trigger names instead of raw strings.","Validate constructor options early and fail fast with allowed values.","Check docs when migrating tooltip libraries for renamed trigger options.","Test each configured trigger in dev to catch the warning."],"tags":["javascript","frontend","tooltips","bad-option"],"backgroundTag":"invalid-enum-value","analyzedSha":"5874c2e6667c69357ab95079421131104bd3fcae","analyzedAt":"2026-09-03T15:41:16.799Z","contentChangedAt":"2026-09-03T15:41:16.799Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}