Bug Tracker

Opened 7 years ago

Closed 6 years ago

#4946 closed bug (fixed)

jQuery.isObject, changeset 6442

Reported by: balazs.endresz Owned by: flesler
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: isObject Cc: balazs.endresz
Blocked by: Blocking:



isObject: function( obj ) { 
  return this.constructor.call(obj) === Object; 

I might be missing something but after staring at this for a while, still seems to be quite odd:

-- First, this is a static method, in which using this is quite dangerous, as someone might save the function in a local variable, where this will be a reference to the window object

-- this here basically refers to jQuery

-- so this.constructor refers to Function

-- you call it in another context and it will return Object, the Object constructor???

If it's not just a typo I'd be really curious how is this supposed to work :)

Change History (6)

comment:1 Changed 7 years ago by dmethvin

  • Resolution set to invalid
  • Status changed from new to closed

Best to ask this on the jQuery Dev forum.

comment:3 Changed 7 years ago by balazs.endresz

  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:4 Changed 6 years ago by flesler

  • Cc balazs.endresz added
  • Owner set to flesler
  • Status changed from reopened to new
  • Version set to 1.3.2

comment:5 Changed 6 years ago by lrbabe

There is definitely something wrong with this function. Do we actually need it? It is used only once in the code in jQuery.extend and there is another problem with this code, replacing the test using jQuery.isObject with false doesn't break the code. All tests of jQuery.extend still pass. I suggest fixing jQuery.extend and getting rid of jQuery.isObject if possible.

comment:6 Changed 6 years ago by john

  • Resolution set to fixed
  • Status changed from new to closed

This method is gone if favor of the improved isObjectLiteral. http://github.com/jquery/jquery/commit/c2bbcd88335cf6f8df4ac9389ecbae90291377fb

Note: See TracTickets for help on using tickets.