Opened 8 years ago

Closed 8 years ago

#13768 closed defect (fixed)

scrollable.js incompatible with AMD, breaks load

Reported by: bill Owned by: ykami
Priority: high Milestone: 1.7
Component: DojoX Mobile Version: 1.6.1
Keywords: 1.7-mobile Cc: Rawld Gill
Blocked By: Blocking:

Description

The problem in #13688 can be more simply and consistently reproduced with the attached demo.html file, which simply requires _ScrollableMixin.js. The problem is in scrollable.js, which has this strange code:

if(typeof dojo === "undefined"){
	dojo = {doc:document, global:window};
	dojox = {mobile:{}};

	dojo.has = function(name){
		var ua = navigator.userAgent;
		if(name === "webkit"){
			return ua.indexOf("WebKit") != -1;
		}
		if(name === "android"){
			return parseFloat(ua.split("Android ")[1]) || undefined;
		}
		if(name === "ie"){
			return parseFloat(ua.split("MSIE ")[1]) || undefined;
		}
		if(name === "touch"){
			return (typeof dojo.doc.documentElement.ontouchstart != "undefined" &&
				navigator.appVersion.indexOf("Mobile") != -1) || !!dojo.has("android");
		}
	};
...

That code is meant to only run when dojo.js doesn't exist, but it's running in the AMD case, apparently due to a race condition. Probably it's running before kernel.js.

Attachments (2)

demo.html (341 bytes) - added by bill 8 years ago.
test file
_ScrollableMixin.js (189 bytes) - added by bill 8 years ago.
simplified _ScrollableMixin.js that still reproduces problem

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by bill

Attachment: demo.html added

test file

Changed 8 years ago by bill

Attachment: _ScrollableMixin.js added

simplified _ScrollableMixin.js that still reproduces problem

comment:1 Changed 8 years ago by ykami

Keywords: 1.7-mobile added
Status: newassigned

Thank you for finding this. As you suggested, checking the global 'define' instead of 'dojo' seems to solve the problem.

comment:2 Changed 8 years ago by ykami

Resolution: fixed
Status: assignedclosed

In [26383]:

Fixes #13768 !strict. Checks the global 'define' rather than 'dojo' to detect whether dojo.js is loaded or not.

Note: See TracTickets for help on using tickets.