RESOLVED FIXED 10782
Classes should not override JSObject::toString(ExecState *)
https://bugs.webkit.org/show_bug.cgi?id=10782
Summary Classes should not override JSObject::toString(ExecState *)
mitz
Reported 2006-09-08 04:59:42 PDT
JSObject::toString(ExecState *) implements the (internal) ToString type conversion operator defined in ECMA-262 9.8. That definition applies to all objects, so classes deriving from JSObject should not -- and have no reason to -- override toString. The correct way to customize the string representation of host objects is to implement in their prototype either a toString() method or the [[DefaultValue]]() internal method. (The native [[DefaultValue]] uses toString, but Firefox compatibility will probably require overriding [[DefaultValue]] as well).
Attachments
Test matrix for an HTML element (4.39 KB, text/html)
2006-09-08 05:08 PDT, mitz
no flags
Unfinished patch (10.28 KB, patch)
2007-03-04 11:32 PST, mitz
no flags
updated patch (32.01 KB, patch)
2007-05-31 16:46 PDT, Sam Weinig
sam: review+
mitz
Comment 1 2006-09-08 05:08:26 PDT
Created attachment 10454 [details] Test matrix for an HTML element This table shows the value of several expressions that (should) invoke ToString, ToPrimitive, [[DefaultValue]], and possibly toString and valueOf. The table shows that, assuming it follows the spec, Firefox overrides [[DefaultValue]] so that when it's called without a hint, it does not invoke valueOf. Classes that currently override JSObject::toString() are DOMObject, DOMNode, JSHTMLElement, Window, FrameArray, Location, Selection and History.
mitz
Comment 2 2007-03-04 11:32:11 PST
Created attachment 13473 [details] Unfinished patch
Sam Weinig
Comment 3 2007-05-31 16:46:16 PDT
Created attachment 14815 [details] updated patch
Sam Weinig
Comment 4 2007-05-31 20:26:40 PDT
Comment on attachment 14815 [details] updated patch Geoff gave me the thumbs up on this baby!
Sam Weinig
Comment 5 2007-05-31 20:27:04 PDT
Landed in r21927.
Note You need to log in before you can comment on or make changes to this bug.