Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#14606 closed defect (fixed)

Dojo 1.7.1 AMD mode and Prototype 1.7 "on" problem

Reported by: Matias Rask Owned by: Kris Zyp
Priority: high Milestone: 1.8
Component: Events Version: 1.7.1
Keywords: on, prototype Cc: cjolif@…
Blocked By: Blocking:


When using Dojo 1.7.1 in AMD mode and Prototype 1.7 on the same page the following error is thrown in Google Chrome 16.0.912.63 when trying to instantiate a dijit.widget (which uses dojo/on)

note: prototype_compressed_1.js is actually the same thing as prototype.js

Uncaught TypeError: Object function (object, listener){				prototype_compressed_1.js:5560
		var keydownSignal = on(object, "keydown", function(evt){
			// munge key/charCode
			var k=evt.keyCode;
			// These are Windows Virtual Key Codes
			var unprintable = (k!=13 || (has("ie") >= 9 && !has("quirks"))) && k!=32 && (k!=27||!has("ie")) && (k<48||k>90) && (k<96||k>111) && (k<186||k>192) && (k<219||k>222) && k!=229;
			// synthesize keypress for most unprintables and CTRL-keys
				var c = unprintable ? 0 : k;
					if(k==3 || k==13){
						return, evt); // IE will post CTRL-BREAK, CTRL-ENTER as keypress natively
					}else if(c>95 && c<106){
						c -= 48; // map CTRL-[numpad 0-9] to ASCII
					}else if((!evt.shiftKey)&&(c>=65&&c<=90)){
						c += 32; // map CTRL-[A-Z] to lowercase
						c = _punctMap[c] || c; // map other problematic CTRL combinations to ASCII
				// simulate a keypress event
				var faux = _synthesizeEvent(evt, {type: 'keypress', faux: true, charCode: c});, faux);
					_trySetKeyCode(evt, faux.keyCode);
		var keypressSignal = on(object, "keypress", function(evt){
			var c = evt.charCode;
			c = c>=32 ? c : 0;
			evt = _synthesizeEvent(evt, {charCode: c, faux: true});
			return, evt);
		return {
			remove: function(){
	} has no method 'include'
_createResponder								prototype_compressed_1.js:5560
observe										prototype_compressed_1.js:5630
Event.Handler.Class.create.start						prototype_compressed_1.js:5745
on										prototype_compressed_1.js:5766
_methodized									prototype_compressed_1.js:438
on										on.js:42
connect										_connect.js:48
connect.connect									connect.js:179
dispatcher.around.advice							aspect.js:189
(anonymous function)								aspect.js:104
declare.onClick									_Widget.js:44
signal.advice									aspect.js:113
target.(anonymous function)							aspect.js:176
declare.connect									_WidgetBase.js:844
inherited									declare.js:191
declare.connect									_OnDijitClickMixin.js:122
declare._attachTemplateNodes							_TemplatedMixin.js:215
declare.buildRendering								_TemplatedMixin.js:129
inherited									declare.js:191
declare.buildRendering								_Container.js:28
declare.create									_WidgetBase.js:323
declare.postscript								_WidgetBase.js:269
a										declare.js:331
dojo.parser.instantiate								parser.js:323
forEach										array.js:279
dojo.parser.instantiate								parser.js:124
dojo.parser.parse								parser.js:582
declare._beforeFillContent							_WidgetsInTemplateMixin.js:36
declare.buildRendering								_TemplatedMixin.js:131
declare.create									_WidgetBase.js:323
declare.postscript								_WidgetBase.js:269
a										declare.js:331
(anonymous function)								main.js:2
runFactory									dojo.js:997
execModule									dojo.js:1123
execModule									dojo.js:1114
checkComplete									dojo.js:1146
onLoadCallback									dojo.js:1311
req.injectUrl.onLoad								dojo.js:1537

Bill Keese suspects that

on(object, "keydown", function(evt){ console.log(evt); });

produces the same result

I'm not sure if this is a Dojo problem or if the fault lies within Prototype.


Change History (6)

comment:1 Changed 7 years ago by Chris Mitchell

Cc: cjolif@… added

We're seeing this problem as well, and will try to get a simple test case put together asap.

comment:2 Changed 7 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

In [29140]:

Don't delegate to target on() method if event type is a function to avoid confusing on() handlers, fixes #14606 !strict

comment:3 Changed 7 years ago by Kris Zyp

Milestone: tbd1.8

comment:4 Changed 7 years ago by bill

Kris, are you sure about this change? I already fixed #15559 so the problem in this ticket may have already been fixed... not sure, I don't understand it exactly.

I don't really care, but just wanted to point out that this change is stopping people from doing something like:

on.once(myWidget,, ...)

comment:5 Changed 7 years ago by Kris Zyp

Bill, I can still reproduce this issue with #15559, so I don't think that fixes the issue. However, #15559 does mean that my fix isn't really correct for interacting with Dijit. But, alternately would this change [29140] fix #15559 so that _WidgetBase doesn't need to worry about function event types anymore (the function would delegate back to on() which would eventually lead to string event types that would be delegated to Dijit)?

comment:6 Changed 7 years ago by bill

OK. I agree your change is another way to fix #15559. Not sure why the patch in #15559 didn't fix this ticket though. Seems like either patch would solve the problem, but anyway I'll take your word for it.

Note: See TracTickets for help on using tickets.