Opened 7 years ago

Closed 5 years ago

Last modified 5 years ago

#16296 closed defect (fixed)

console.debug(NaN) produces error in IE9

Reported by: djtore Owned by: Brandon Payton <brandon@…>
Priority: undecided Milestone: 1.7.6
Component: Core Version: 1.8.1
Keywords: Cc:
Blocked By: Blocking:

Description

Environment: Windows 7, IE 9.

Somewhere in my code I have a console.debug() expression where the parameter evaluates to NaN

    console.debug(value); // value is NaN

I see in IE 9's developer console the following error message:

    SCRIPT5029: Array length must be a finite positive integer 

I can trace this to an Array.apply() expression in some code in dojo/_base/kernel.js

	if(has("dojo-guarantee-console")){
		typeof console != "undefined" || (console = {});
		//	Be careful to leave 'log' always at the end
		var cn = [
			"assert", "count", "debug", "dir", "dirxml", "error", "group",
			"groupEnd", "info", "profile", "profileEnd", "time", "timeEnd",
			"trace", "warn", "log"
		];
		var tn;
		i = 0;
		while((tn = cn[i++])){
			if(!console[tn]){
				(function(){
					var tcn = tn + "";
					console[tcn] = ('log' in console) ? function(){
// Produces error message when arguments contains an element with 
// value NaN			
			var a = Array.apply({}, arguments); 
						a.unshift(tcn + ":");
						console["log"](a.join(" "));
					} : function(){};
					console[tcn]._fake = true;
				})();
			}
		}
	}

This can simply be reproduced with the expression

    Array.apply({}, [NaN])

or, when Dojo is loaded,

  console.debug(NaN);

Change History (7)

comment:1 Changed 7 years ago by djtore

Clarification: It's in the case where the arguments object contains A SINGLE element with NaN value. Then the expression

var a = Array.apply({}, arguments); 

is the equivalent of

var a = new Array(NaN);

When invoking the Array-constructor with a single numeric element, this is interpreted as the size of the array, and it is an error not to invoke it with a finite number (like NaN or Infinity)

comment:2 Changed 7 years ago by bill

Component: GeneralCore
Summary: console.debug(NaN) produces error in IE 9console.debug(NaN) produces error in IE9

comment:3 Changed 5 years ago by Brandon Payton <brandon@…>

Owner: set to Brandon Payton <brandon@…>
Resolution: fixed
Status: newclosed

In 97861d95302c4e4e08de697dc563f9a0786e1d8d/dojo:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:4 Changed 5 years ago by Brandon Payton <brandon@…>

In 7890c4706748ab1a7a229b6ba140c83e39efa798/dojo:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:5 Changed 5 years ago by Brandon Payton <brandon@…>

In 385185cde2d8839968fc90020ae6505ec6806b68/dojo:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:6 Changed 5 years ago by Brandon Payton <brandon@…>

In 0299ef009c1bf5708103932641ae405807c7d419/dojo:

Error: Processor CommitTicketReference failed
Unsupported version control system "git": Can't find an appropriate component, maybe the corresponding plugin was not enabled? 

comment:7 Changed 5 years ago by bill

Milestone: tbd1.7.6
Note: See TracTickets for help on using tickets.