Opened 7 years ago

Closed 7 years ago

#15876 closed defect (fixed)

_loadTest.js gets exception after alternate AMD loader support (IE8)

Reported by: bill Owned by: Douglas Hays
Priority: undecided Milestone: 1.8.1
Component: Dijit Version: 1.8.0
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

After my changes in #15616, Tooltip_quirks_mouse.html is hanging on IE8, when loading ../quirks.html?file=test_Tooltip.html. Problem can be reproduced by loading that URL directly too.

The problem is in the script related code:

for(var i=0; i <scripts.length; i++){
	var script = scripts[i];
	if(!script['_oldGetAttribute']){
		var src = script.getAttribute('_oldsrc');
		if(src){
			script._oldGetAttribute = script.getAttribute;
			script.getAttribute = function(attr){ if(/^src$/i.test(attr))attr='_oldsrc';return script._oldGetAttribute(attr) };
		}
	}
}

which is likely running while the AMD loader is inserting <script> tags to load new modules. It gets an exception about _oldGetAttribute.

Attachments (1)

15876.patch (1002 bytes) - added by Douglas Hays 7 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by bill

Owner: changed from bill to Douglas Hays
Status: newassigned
Summary: _loadTest.js broken after AMD loader support_loadTest.js broken after alternate AMD loader support

comment:2 Changed 7 years ago by bill

Description: modified (diff)
Summary: _loadTest.js broken after alternate AMD loader support_loadTest.js broken after alternate AMD loader support (IE8)

comment:3 Changed 7 years ago by bill

Description: modified (diff)
Milestone: tbd1.8.1
Summary: _loadTest.js broken after alternate AMD loader support (IE8)_loadTest.js gets exception after alternate AMD loader support (IE8)

That loop is incorrect because the closure is referencing the variable "script", but then you change the value of script afterwards. In other words, getAttribute() for any script will try to call _oldGetAttribute() on the last script in the file.

Having said that though, I will let you update it because I don't understand why that code to override getAttribute() is there in the first place, and it might no longer make sense with AMD (which dynamically injects script tags).

Last edited 7 years ago by bill (previous) (diff)

Changed 7 years ago by Douglas Hays

Attachment: 15876.patch added

comment:4 Changed 7 years ago by Douglas Hays

For some reason I'm unable to recreate this, and the code is needed since the src attributes of the scripts can be relative and loading them via _loadTests changes the base path. I tweaked the code to make the script variable local. Please lte me know if this fixes the problem.

comment:5 Changed 7 years ago by bill

That does fix the exception loading dijit/tests/quirks.html?file=test_Tooltip.html, so it's definitely an improvement.

It still seems like _loadTest.js will fail with an AMD syntax file though, because that block of code will affect the dynamically inserted <script> tags which already have the right path. I didn't try it though.

comment:6 Changed 7 years ago by Douglas Hays

dijit/tests/quirks.html?file=layout/ContentPane-auto-require.html loaded and ran for me on IE8, but so did test_Tooltip.html

comment:7 Changed 7 years ago by Douglas Hays

Resolution: fixed
Status: assignedclosed

In [29513]:

Fixes #15876. Change script variable to a function local to preserve value.

Note: See TracTickets for help on using tickets.