Opened 5 years ago

Last modified 3 years ago

#18244 closed defect

lang.js fix up the isAlien and _toArray — at Version 5

Reported by: [email protected] Owned by: dylan
Priority: high Milestone: 1.13
Component: Core Version: 1.10.0
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

Hi sir, I have two question as following

(1) isAlien will return true if it is a built in function, but the source file of this method, why it has a !lang.isFunction(it)?

isAlien: function(it){
return it && !lang.isFunction(it) && /\{\s*\[native code\]\s*\}/.test(String(it)); // Boolean
}

(2) IE9 and above browser can cover the HTMLCollection to Javascript object, In the source, it will call the slow function.

_toArray: has("ie") ?
			(function(){
				function slow(obj, offset, startWith){
					var arr = startWith||[];
					for(var x = offset || 0; x < obj.length; x++){
						arr.push(obj[x]);
					}
					return arr;
				}
				return function(obj){
					return ((obj.item) ? slow : efficient).apply(this, arguments);  //IE 9 and above, will call the slow function
				};
			})() : efficient,

Change History (5)

comment:1 Changed 5 years ago by dylan

Milestone: tbd1.11
Priority: undecidedhigh

comment:2 Changed 5 years ago by mdlabrec

Pull request for isAlien issue: https://github.com/dojo/dojo/pull/123

comment:3 Changed 4 years ago by dylan

Owner: set to dylan
Status: newassigned

comment:4 Changed 4 years ago by bill

Component: GeneralCore
Description: modified (diff)

comment:5 Changed 4 years ago by bill

Description: modified (diff)

As I wrote in the PR, ISTM that isAlien() is obeying its spec, which implies that it returns false for normal functions.

Last edited 4 years ago by bill (previous) (diff)
Note: See TracTickets for help on using tickets.