[Webkit-unassigned] [Bug 167708] [Cocoa] An exported Objective C class’s prototype and constructor don't persist across JSContext deallocation

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon May 15 22:59:51 PDT 2017


Keith Miller <keith_miller at apple.com> changed:

           What    |Removed                     |Added
                 CC|                            |keith_miller at apple.com
           Assignee|webkit-unassigned at lists.web |keith_miller at apple.com
                   |kit.org                     |

--- Comment #4 from Keith Miller <keith_miller at apple.com> ---
I would propose a different solution to fix this. I think we should just set the .prototype property on A and make it read-only and non-configurable. Then we can run the same code for constructing ObjC classes as we do for host constructors. This also has the nice property that it does what people would expect from JS.

There are a couple of behavior changes to consider with this proposal, however: 

1) If you set the .prototype property on A, right now it will work but do nothing. This change will make code that relies on changing the .prototype property 

2) If you make two constructors for your class both share the same .prototype. This change would make them have different prototypes, which seems closer to what one would expect from JS.

3) If you extend (in JS) your constructor, any super() calls don't respect new.target. This change would make it respect new.target. (I didn't test this but the API code doesn't call createSubclassStructure so I assume it doesn't)

The only thing I would worry about causing incompatible changes is 2. I could totally imagine someone making two constructors, say A and B, for their class and only setting properties on A's .prototype. Currently instances of B will still see A's .prototype properties since both constructors will share the same .prototype object.

I'm not sure if that's something we should worry about. I would guess most users only put their constructors on the global object. Geoff, do you have any insight here?

You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170516/cd6eb398/attachment.html>

More information about the webkit-unassigned mailing list