Hi,

Sorry if my question is stupid or does not really belongs here. I will be
thankful to get some clarification on es specs since I just discovered that
my interpretation of how getter / setters are supposed to behave appears to
be different from the behavior in observed in modern browsers.

var foo = Object.create({}, {
    bar: {
        get: function() {
            return this._foo;
        },
        set: function(value) {
            return this._foo = 'Hello ' + value;
        }
    }
});

var bar = foo.bar = 'setter';
if (foo.bar !== bar) throw new Error('Unexpected');

The code will throw an error cause bar will be 'setter' while foo.bar will
be 'Hello setter'.  I was expecting that `bar' would've get value returned
by a setter (or at least getter of foo). And this is not the case nor with
FF nor with Safari implementations. Behavior is the same if getters and
setters are used instead. Is it expected behavior ? If answer is yes, is
there any point of returning anything from setter ?

I am also afraid that this might break some of the frameworks in rare cases
like in this example above. (a = b = c is commonly used syntax)

Thanks a lot!
--
Irakli Gozalishvili
Web: http://www.jeditoolkit.com/
Phone: +31 614 205275
Address: Taksteeg 3 - 4, 1012PB Amsterdam, Netherlands
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to