Javascript Float32Array集属性在firefox中不起作用

Javascript Float32Array集属性在firefox中不起作用,javascript,google-chrome,firefox,Javascript,Google Chrome,Firefox,我已经在Float32Array中添加了3个名为“x”、“y”和“z”的属性。 getter在chrome和firefox中都能很好地工作,但似乎setter只在chrome中工作。为什么呢?是虫子吗?有没有办法让它在firefox中工作 Object.defineProperty(Float32Array.prototype, 'x', { get: function(){ return this[0]; }, set: function(x){

我已经在Float32Array中添加了3个名为“x”、“y”和“z”的属性。 getter在chrome和firefox中都能很好地工作,但似乎setter只在chrome中工作。为什么呢?是虫子吗?有没有办法让它在firefox中工作

Object.defineProperty(Float32Array.prototype, 'x', {
    get: function(){
        return this[0];
    },
    set: function(x){
        this[0] = x;
    }
});


// creating a Float32Array-Vector using mjs.js  
var vector = V3.$(1,2,3);

// works fine
document.writeln(vector.x);

// works in chrome but not in firefox
vector.x = vector.y + vector.z;

我发现这个问题很有趣,并对它进行了研究。我能重现你面临的问题。二传手永远不会被调用,但getter会被调用。在探索中,发现以下文本:

JavaScript 1.8.1 note
Starting in JavaScript 1.8.1, setters are no longer called when setting properties in object and array initializers.
请看网址:

还有更多参考资料:

原因被称为安全漏洞(受影响的twitter)

在chromium中对此进行讨论,这里发生的事情是Firefox不允许在类型化数组上设置任何非数字属性;任何这样的集合都将被忽略。它们在搜索原型链之前被忽略,这就是为什么原型上的setter没有被调用

我不清楚根据规范这里的正确行为是什么;这一地区的情况发生了几次变化


注意

感谢您的研究。我不明白的是,我没有在对象或数组初始值设定项中设置属性,所以这真的应该不起作用吗?