Closed
Bug 526491
Opened 15 years ago
Closed 1 year ago
Define .constructor on DOM objects without needing a resolve hook
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: peterv, Assigned: peterv)
Details
Attachments
(1 file, 1 obsolete file)
8.32 KB,
patch
|
peterv
:
review-
|
Details | Diff | Splinter Review |
Still need to do something about Location, it doesn't have ALLOW_PROP_MODS_TO_PROTOTYPE and so I can't define a constructor property on its prototype. I might be able to just add a constructor attribute on nsIDOMLocation.
Assignee | ||
Comment 1•15 years ago
|
||
Blake, we can't trick hasOwnProperty using JSPROP_PERMANENT | JSPROP_SHARED because the wrapper and the prototype have different classes :-/.
Comment 2•15 years ago
|
||
So, I don't see an easy way around this... Either we have to bite the bullet and eagerly define .constructor on all nodes or have a resolve hook (they exist explicitly to avoid eagerly defining properties, after all). Brendan, have I missed something?
Comment 3•15 years ago
|
||
Use a resolve hook if you must. This is all about location, a singleton, so paying up front (once per window/frame) whether in a prototype object or in the direct location object could hurt Tp, I take it. Has anyone measured? /be
Comment 4•15 years ago
|
||
(In reply to comment #3) > Use a resolve hook if you must. This is all about location, a singleton, so > paying up front (once per window/frame) whether in a prototype object or in the > direct location object could hurt Tp, I take it. Has anyone measured? brendan, the problem is that this isn't just about location. We're talking about the resolve hook on all nodes (currently nsNodeSH::NewResolve). The property in question is .constructor, it's a property that's (probably) rarely used, but it isn't free to define and it has to be hasOwnProperty to the nodes.
Comment 5•15 years ago
|
||
Who ever said constructor has to be "own" for all nodes? Don't tell me some HTML5 or WebAPI crack-spec! js> d = new Date (new Date(1258478166310)) js> d.constructor function Date() {[native code]} js> d.hasOwnProperty('constructor') false Note that constructor is not "own", it is delegated to constructor.prototype. Do that and prosper. /be
Assignee | ||
Comment 6•15 years ago
|
||
This just puts .constructor on the prototype. I also solved the problem for Location by allowing PostCreatePrototype to add a constructor property to a XPCWrappedNativeProto.
Attachment #410243 -
Attachment is obsolete: true
Assignee | ||
Updated•15 years ago
|
Attachment #414310 -
Flags: superreview?(mrbkap)
Attachment #414310 -
Flags: review?(jst)
Assignee | ||
Updated•15 years ago
|
Attachment #414310 -
Flags: superreview?(mrbkap)
Attachment #414310 -
Flags: review?(jst)
Attachment #414310 -
Flags: review-
Assignee | ||
Comment 7•15 years ago
|
||
Comment on attachment 414310 [details] [diff] [review] v2 Actually, there's still some mochitest failures with this.
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
Updated•2 years ago
|
Severity: normal → S3
Assignee | ||
Comment 8•1 year ago
|
||
I think our new bindings already do this.
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•