{"record":{"id":"9cb70e0e93704cea","repo":"Meituan-Dianping/mpvue","slug":"passive-and-prevent-can-t-be-used-together-passiv","errorCode":null,"errorMessage":"passive and prevent can't be used together. Passive handler can't prevent default event.","messagePattern":"passive and prevent can't be used together\\. Passive handler can't prevent default event\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/weex-template-compiler/build.js","lineNumber":1263,"sourceCode":") {\n  (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });\n}\n\nfunction addHandler (\n  el,\n  name,\n  value,\n  modifiers,\n  important,\n  warn\n) {\n  // warn prevent and passive modifier\n  /* istanbul ignore if */\n  if (\n    process.env.NODE_ENV !== 'production' && warn &&\n    modifiers && modifiers.prevent && modifiers.passive\n  ) {\n    warn(\n      'passive and prevent can\\'t be used together. ' +\n      'Passive handler can\\'t prevent default event.'\n    );\n  }\n  // check capture modifier\n  if (modifiers && modifiers.capture) {\n    delete modifiers.capture;\n    name = '!' + name; // mark the event as captured\n  }\n  if (modifiers && modifiers.once) {\n    delete modifiers.once;\n    name = '~' + name; // mark the event as once\n  }\n  /* istanbul ignore if */\n  if (modifiers && modifiers.passive) {\n    delete modifiers.passive;\n    name = '&' + name; // mark the event as passive\n  }","sourceCodeStart":1245,"sourceCodeEnd":1281,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/packages/weex-template-compiler/build.js#L1245-L1281","documentation":"The compiler rejects combining the .prevent and .passive event modifiers. A passive listener promises the browser it will not call preventDefault(), so .prevent would be a no-op; the compiler warns at compile time in development to catch the contradiction early.","triggerScenarios":"Writing a v-on handler with both modifiers, e.g. v-on:scroll.prevent.passive or @touchmove.passive.prevent, so genEvent Handler modifiers contain both prevent and passive when warn is enabled in dev builds.","commonSituations":"Optimizing scroll/touch performance with .passive while also trying to block default behavior like pull-to-refresh; developers copy modifiers from different examples and combine them.","solutions":["Remove .passive if you actually need preventDefault()","Remove .prevent if the handler should stay passive and not block default behavior","Move preventDefault logic to a separate non-passive handler"],"exampleFix":"// before\n<div @scroll.prevent.passive=\"onScroll\">\n// after\n<div @scroll.passive=\"onScroll\">","handlingStrategy":"validation","validationCode":"function hasConflictingModifiers(directive) {\n  const m = directive.arg || '';\n  return /\\.prevent[\\w.]*\\.passive|\\.passive[\\w.]*\\.prevent/.test(directive.expression || m);\n}\n// scan template source: /@\\w+(?:\\.\\w+)*\\.(?:prevent[\\w.]*passive|passive[\\w.]*prevent)/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never combine .prevent with .passive on v-on","Grep templates for /\\.prevent[\\w.]*\\.passive/ in CI","Remember .passive is a performance hint that forbids preventDefault"],"tags":["events","modifiers","vue","weex"],"backgroundTag":"passive-prevent-modifier-conflict","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}