Dojo 1.7.1 AMD with Prototype 1.7

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dojo 1.7.1 AMD with Prototype 1.7

mathewrapid

Hi,

I've a problem using Dojo 1.7.1 and Prototype 1.7 at the same time.

Prototype is included before Dojo.

I get an error when I try to create a new dijit widget.

var myWidget = new MyWidget();

What I get is (in Google Chrome 16.0.912.63 m):

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
			// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp
			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
			if(unprintable||evt.ctrlKey){
				var c = unprintable ? 0 : k;
				if(evt.ctrlKey){
					if(k==3 || k==13){
						return listener.call(evt.currentTarget, 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
					}else{
						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});
				listener.call(evt.currentTarget, faux);
				if(has("ie")){
					_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 listener.call(this, evt);
		});
		return {
			remove: function(){
				keydownSignal.remove();
				keypressSignal.remove();
			}
		};
	} 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

Any help is appreciated.

Reply | Threaded
Open this post in threaded view
|

Re: Dojo 1.7.1 AMD with Prototype 1.7

Bill Keese-2
Hmm, looks like prototype has added an on() method to DOMNodes (or maybe just a particular DOMNode like document, <html>, or <body>?   Anyway, that will mess up the dojo/on code.

If you could make up a testcase and file a ticket Kris can probably look at it.   Hopefully you can simplify the test case.   I suspect just calling

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

will trigger the exception, for the right object.

On Mon, Jan 9, 2012 at 10:20 PM, mathewrapid <[hidden email]> wrote:

Hi,

I've a problem using Dojo 1.7.1 and Prototype 1.7 at the same time.

Prototype is included before Dojo.

I get an error when I try to create a new dijit widget.

var myWidget = new MyWidget();

What I get is (in Google Chrome 16.0.912.63 m):

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
			// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/VirtualKeyCodes.asp
			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
			if(unprintable||evt.ctrlKey){
				var c = unprintable ? 0 : k;
				if(evt.ctrlKey){
					if(k==3 || k==13){
						return listener.call(evt.currentTarget, 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
					}else{
						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});
				listener.call(evt.currentTarget, faux);
				if(has("ie")){
					_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 listener.call(this, evt);
		});
		return {
			remove: function(){
				keydownSignal.remove();
				keypressSignal.remove();
			}
		};
	} 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

Any help is appreciated.



View this message in context: Dojo 1.7.1 AMD with Prototype 1.7
Sent from the Dojo Toolkit mailing list archive at Nabble.com.

________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest



________________________________________________________
Dojotoolkit: http://dojotoolkit.org
Reference Guide: http://dojotoolkit.org/reference-guide
API Documentation: http://dojotoolkit.org/api
Tutorials: http://dojotoolkit.org/documentation

[hidden email]
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest