Bug Tracker

Ticket #4946 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

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
Blocking: Blocked by:



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

comment:1 Changed 6 years ago by dmethvin

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

Best to ask this on the jQuery Dev forum.

comment:3 Changed 6 years ago by balazs.endresz

  • Status changed from closed to reopened
  • Resolution invalid deleted

comment:4 Changed 6 years ago by flesler

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

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

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

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.