{"record":{"id":"cb41ed1483d5c402","repo":"libnyanpasu/clash-nyanpasu","slug":"proxy-addeventlistener","errorCode":null,"errorMessage":"Proxy addEventListener:","messagePattern":"Proxy addEventListener:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"frontend/nyanpasu/index.html","lineNumber":25,"sourceCode":"      href=\"./assets/image/logo.ico\"\n      type=\"image/x-icon\"\n    />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <title><%- title %></title>\n    <%- injectScript %>\n    <script>\n      ;(function () {\n        var _matchMedia = window.matchMedia\n        window.matchMedia = function () {\n          var v = _matchMedia.apply(null, arguments)\n          if (!v.addEventListener) {\n            v.addEventListener = function () {\n              if (arguments.length < 2 || arguments[0] !== 'change') {\n                console.error('Cannot proxy addEventListener:', arguments)\n                return\n              }\n              if (arguments.length > 2) {\n                console.warn('Proxy addEventListener:', arguments)\n              }\n              v.addListener(arguments[1])\n            }\n          }\n          return v\n        }\n      })()\n    </script>\n  </head>\n  <body>\n    <div id=\"root\"></div>\n    <script type=\"module\" src=\"/src/main.tsx\"></script>\n  </body>\n</html>\n","sourceCodeStart":7,"sourceCodeEnd":40,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/frontend/nyanpasu/index.html#L7-L40","documentation":"The bootstrap script in index.html wraps a global object's addEventListener to intercept 'change' listeners. If addEventListener is called with fewer than 2 arguments or with an event name other than 'change', it logs console.error('Cannot proxy addEventListener:', arguments) and refuses to register the listener. If called with more than 2 arguments but event 'change', it logs console.warn('Proxy addEventListener:', arguments) and registers via addListener.","triggerScenarios":"Any script (or webview-injected code) calling that proxied object's addEventListener with an event type other than 'change' (or with missing handler argument) — e.g. document/element-style code doing el.addEventListener('click', fn) on the proxied global, or a library adding a change listener with extra options (capture/useCapture third argument).","commonSituations":"A vendored library or user script assumes standard DOM addEventListener semantics (any event name, optional options object) but the proxied object only supports a single 'change' event; upgrade of a dependency introduces new addEventListener calls for other events.","solutions":["Check the logged `arguments` to see which event name and how many arguments were passed.","If the code registers a non-'change' event on this object, that's unsupported — rework the script to attach other events to the proper target (document/window) instead of this proxied object.","If it's a legitimate 'change' listener with a third options argument, use addListener(handler) directly or pass only (event, handler) to silence the warn.","If you control the wrapper and new event support is needed, extend the proxy to forward additional event types instead of erroring."],"exampleFix":"// before (third argument triggers the proxy warning)\nv.addEventListener('change', handler, { passive: true });\n// after\nv.addEventListener('change', handler);\n// or\nv.addListener(handler);","handlingStrategy":"fallback","validationCode":"if (typeof v.addEventListener === 'function' && arguments.length >= 2 && arguments[0] === 'change') {\n  v.addEventListener('change', arguments[1]);\n} else {\n  v.addListener(arguments[1]);\n}","typeGuard":"function supportsAddEventListener(v: unknown): v is { addEventListener(type: 'change', fn: () => void): void } {\n  return typeof v === 'object' && v !== null &&\n    typeof (v as any).addEventListener === 'function';\n}","tryCatchPattern":null,"preventionTips":["On this proxied object, call addEventListener only as (type: 'change', handler) with exactly two arguments.","Attach non-'change' events to the proper DOM target (document/window), not the proxied global.","Use addListener(handler) directly for change listeners to bypass the proxy checks.","Pin/audit dependency upgrades that might add new addEventListener calls on the proxied object."],"tags":["webview","dom","event-listener","console-warning"],"backgroundTag":"unsupported-operation","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}