Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AFBF2C325 for ; Wed, 2 May 2012 22:25:14 +0000 (UTC) Received: (qmail 96628 invoked by uid 500); 2 May 2012 22:25:14 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 96597 invoked by uid 500); 2 May 2012 22:25:14 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 96589 invoked by uid 99); 2 May 2012 22:25:14 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 May 2012 22:25:14 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 May 2012 22:25:12 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 1BAF742C8A8 for ; Wed, 2 May 2012 22:24:51 +0000 (UTC) Date: Wed, 2 May 2012 22:24:51 +0000 (UTC) From: "Filip Maj (JIRA)" To: callback-dev@incubator.apache.org Message-ID: <1278006522.19077.1335997491114.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <33242585.25900.1334438238718.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Issue Comment Edited] (CB-514) Do we need to monkey patch addEventListener()? MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-514?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13266964#comment-13266964 ] Filip Maj edited comment on CB-514 at 5/2/12 10:24 PM: ------------------------------------------------------- I would love to get rid of the monkeypatching but, as far as I can tell, if we start listening for the various device events willy-nilly we'd be using up more resources. In general the handler counting is there to trigger device listening of system events only when necessary. Setting to Won't Fix for now but if we can figure out a way around these issues then I am all for reopening. was (Author: filmaj): I would love to get rid of the monkeypatching but, as far as I can tell, unless we start listening for the various device events willy-nilly we'd be using up more resources. In general the handler counting is there to trigger device listening of system events only when necessary. Setting to Won't Fix for now but if we can figure out a way around these issues then I am all for reopening. > Do we need to monkey patch addEventListener()? > ---------------------------------------------- > > Key: CB-514 > URL: https://issues.apache.org/jira/browse/CB-514 > Project: Apache Callback > Issue Type: Bug > Components: CordovaJS > Reporter: Patrick Mueller > Assignee: Filip Maj > > discussion here: http://markmail.org/message/mghdkbumdyjhmaye > I noticed in cordova.js we override the following messages on window/document: > {noformat} > document.addEventListener = function(evt, handler, capture) {...} > window.addEventListener = function(evt, handler, capture) {...} > document.removeEventListener = function(evt, handler, capture) {...} > window.removeEventListener = function(evt, handler, capture) {...} > {noformat} > aka as "monkey patching". > Apparently, we aren't sure why we're doing this. My guess is that we've done this in the past when dispatching user-land events wasn't possible, and so trapping listeners was the only way to get the listeners so you could send them events. > It would be nice to remove this monkey patching, if we can, by using: > {noformat} > event = document.createEvent('Events') > event.initEvent(blah) > window.dispatchEvent(event) > // or document.dispatchEvent(event) > {noformat} > We'll need to figure out if this works on all our platforms. Even if it doesn't work on all of them, I think we should only use monkey patching on platforms that we have to. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira