Status: Accepted
Owner: kpreid.switchb.org
CC: [email protected]
Labels: Type-Defect Priority-Low Usability
New issue 1746 by kpreid.switchb.org: toString as accessor property doesn't
work in ES5/3
http://code.google.com/p/google-caja/issues/detail?id=1746
If o.toString is overridden as an accessor property under ES5/3, String(o)
or ''+o will not invoke the override. This is because toString is
virtualized and the hook to cause native .toString() to invoke it is only
applied on assignment to toString, not on defineProperty.
This affects Domado since its toString methods are defined as overridable
using accessors (which is not actually necessary under ES5/3). It was not
caught by test-domado-dom-guest testToString since it uses .toString()
explicitly which is translated into .m___('toString', []).
The only uses of the opt_setterHook feature in virtualize() are toString
and valueOf, so it looks like we can just change that hook into a
defineProperty hook (implicitly invoked also by assignment). However,
without a concrete value we can't do the early (!isFunction(val)) check; as
noted in the comments, it is unclear to me what benefit that check provides
and whether it is safe to do it at a later time.
A workaround rather than a fix would be to have Domado skip generating
override accessors when running under ES5/3; this might also improve
performance for non-virtualized properties.
Versions r5410-r5424, probably at least since r5369.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
---
You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.