- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Fri, 05 Oct 2012 15:47:10 -0400
- To: public-script-coord@w3.org
Right now the spec says that given this: [Constructor(DOMString arg)] interface Foo { stringifier DOMString myString(); // always returns the argument // passed to the constructor } and this JS: var foo = new Foo("abc"); alert(foo); Foo.prototype.myString = function() { return "xyz"; } alert(foo); the two alerts will show "abc" and "xyz" respectively. Furthermore this JS: var foo = new Foo("abc"); Object.defineProperty(foo, "myString", { get: function() { throw "FAIL"; } }) alert(foo); will throw an exception. This seems pretty unexpected to me. I would expect the behavior of toString() to not be affected by changes to the myString property of the object (or even the prototype); instead it seems like it should call the canonical myString... Thoughts? And in particular, the way the spec is phrased right now means that this bit of WebIDL from HTMLAnchorElement: stringifier attribute DOMString href; does not have the same behavior as this bit would: attribute DOMString href; stringifier DOMString(); with prose defining DOMString to do the same thing as the href getter. -Boris
Received on Friday, 5 October 2012 19:47:37 UTC