{"record":{"id":"0e23fdde65c4dbd1","repo":"emberjs/ember.js","slug":"you-marked-this-listener-as-passive-meaning-tha","errorCode":null,"errorMessage":"You marked this listener as 'passive', meaning that you must not call 'event.preventDefault()': \\n\\n${userProvidedCallback.name || `{anonymous function}`}","messagePattern":"You marked this listener as 'passive', meaning that you must not call 'event\\.preventDefault\\(\\)': \\\\n\\\\n(.+?)`\\}","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@glimmer/runtime/lib/modifiers/on.ts","lineNumber":194,"sourceCode":"    // https://bugs.chromium.org/p/chromium/issues/detail?id=770208\n    if (shouldUpdate) {\n      if (once !== undefined || passive !== undefined || capture !== undefined) {\n        options = { once, passive, capture };\n      }\n    }\n\n    if (shouldUpdate) {\n      let callback = userProvidedCallback;\n\n      if (DEBUG) {\n        callback = userProvidedCallback.bind(untouchableContext);\n\n        if (passive) {\n          let _callback = callback;\n\n          callback = (event) => {\n            event.preventDefault = () => {\n              throw new Error(\n                `You marked this listener as 'passive', meaning that you must not call 'event.preventDefault()': \\n\\n${\n                  userProvidedCallback.name || `{anonymous function}`\n                }`\n              );\n            };\n\n            return _callback(event);\n          };\n        }\n      }\n\n      this.listener = {\n        eventName,\n        callback,\n        userProvidedCallback,\n        once,\n        passive,\n        capture,","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/emberjs/ember.js/blob/26f97246a8bf2e28edf26ac3093da2e86c04ffc5/packages/@glimmer/runtime/lib/modifiers/on.ts#L176-L212","documentation":"A listener registered with the `on` modifier was marked `passive=true`, which tells the browser the handler will never call `event.preventDefault()`. In DEBUG builds, updateListener wraps the callback and monkey-patches `event.preventDefault` to throw if the handler calls it anyway, so the developer learns immediately that the passive contract is broken.","triggerScenarios":"Using {{on \"scroll\" this.handler passive=true}} (or similar) and then invoking event.preventDefault() inside this.handler. The wrapped callback throws the moment preventDefault is called on the event object.","commonSituations":"Scroll/touch/wheel listeners added for performance with `passive` but whose handler conditionally calls preventDefault; copying a handler that previously worked without the passive option.","solutions":["Remove `event.preventDefault()` from the passive handler's code.","If preventDefault is genuinely needed, drop `passive=true` from the `on` modifier usage.","Split the logic: use a non-passive listener when preventDefault is required, or prevent the default via a different mechanism (e.g. CSS `overflow` handling, `touch-action`)."],"exampleFix":"{{!-- before --}}\n<div {{on \"wheel\" this.onWheel passive=true}}>...</div>\n\n// before\nonWheel(event) { event.preventDefault(); /* ... */ }\n\n{{!-- after --}}\n<div {{on \"wheel\" this.onWheel}}>...</div>","handlingStrategy":"validation","validationCode":"function assertNoPreventDefault(fn) {\n  const src = Function.prototype.toString.call(fn);\n  if (/preventDefault\\s*\\(/.test(src)) {\n    throw new Error(`${fn.name || 'handler'} calls preventDefault; cannot be passive`);\n  }\n}\nassertNoPreventDefault(this.onWheel); // before registering with passive=true","typeGuard":null,"tryCatchPattern":"try {\n  handler(event);\n} catch (e) {\n  if (String(e.message).includes(\"you must not call 'event.preventDefault()'\")) {\n    // remove passive=true from the modifier or drop preventDefault in handler\n  } else throw e;\n}","preventionTips":["Never call preventDefault in handlers registered with passive=true (scroll/wheel/touch).","Do DOM-dependent default prevention in a separate non-passive listener.","Keep passive handlers pure: observe, don't cancel.","Test handlers with passive:true in dev so DEBUG wrapping catches violations."],"tags":["ember","glimmer","dom-events","passive-listener","developer-error"],"backgroundTag":"preventdefault-in-passive-listener","analyzedSha":"26f97246a8bf2e28edf26ac3093da2e86c04ffc5","analyzedAt":"2026-09-01T05:01:28.182Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}