Bug 4000 - Object.prototype is missing isPrototypeOf
Summary: Object.prototype is missing isPrototypeOf
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 412
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Anders Carlsson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-14 10:41 PDT by Geoffrey Garen
Modified: 2022-01-02 19:41 PST (History)
0 users

See Also:


Attachments
Implement isPrototypeOf (7.28 KB, patch)
2005-12-14 07:47 PST, Anders Carlsson
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Geoffrey Garen 2005-07-14 10:41:10 PDT
Section 15.2.4 of ECMA-262
Comment 1 Anders Carlsson 2005-12-14 07:47:09 PST
Created attachment 5078 [details]
Implement isPrototypeOf
Comment 2 Darin Adler 2005-12-14 09:44:00 PST
Comment on attachment 5078 [details]
Implement isPrototypeOf

r=me
Comment 3 Darin Adler 2005-12-14 09:44:44 PST
Comment on attachment 5078 [details]
Implement isPrototypeOf

Wait, should this work for a non-object value if that just happens to be set as
the prototype?
Comment 4 Anders Carlsson 2005-12-14 10:03:55 PST
(In reply to comment #3)
> (From update of attachment 5078 [details] [edit])
> Wait, should this work for a non-object value if that just happens to be set as
> the prototype?
> 

I don't think so, since you can't invoke methods on non-objects, and they can't have prototype properties 
anyway, but maybe I'm misunderstanding something
Comment 5 Geoffrey Garen 2005-12-14 10:40:32 PST
I don't think it's right to test for v being NULL. JSValues should never be null, only jsNull().
Comment 6 Darin Adler 2005-12-17 09:01:41 PST
(In reply to comment #5)
> I don't think it's right to test for v being NULL. JSValues should never be null, only jsNull().

That's a good point. The check for 0/NULL is unnecessary and should omitted.
Comment 7 Darin Adler 2005-12-17 09:04:53 PST
(In reply to comment #4)
> (In reply to comment #3)
> > Wait, should this work for a non-object value if that just happens to be set as the prototype?
> 
> I don't think so, since you can't invoke methods on non-objects, and they can't have prototype properties 
> anyway, but maybe I'm misunderstanding something

You're right. I had it backwards.

To restate what you said in a more confusing but more thorough way, "this" must be an object so we don't have to look at non-
object prototypes since they can't possibly be equal to this. And the argument to the method is the object to find a prototype "of". 
Thus if the argument is not an object we instantly know "this" is not its prototype since only objects have prototypes.
Comment 8 Anders Carlsson 2005-12-18 05:29:05 PST
Committed (with some small changes that Geoffrey approved)
Comment 9 Diego Pino 2021-06-08 07:03:11 PDT
bug.
Comment 10 Diego Pino 2022-01-02 19:41:24 PST
bug.