在__proto__上设置的属性会直接在Chrome中设置属性

时间:2010-12-14 15:31:29

标签: javascript google-chrome

使用这个html:

<select><option>hi</option></select>

<script type="text/javascript">

var select = document.getElementsByTagName("select")[0];

select.__proto__.setValue = "foo";
select.setValue = "bar";

alert(select.setValue);

</script>

在Firefox和Opera中,输出为“bar”,但在Chrome中,输出为“foo”。如果我跳过__proto__定义,则所有浏览器都输出“bar”。

如何让Chrome(8.0)输出属性的对象特定值,而不是原型上设置的值?

1 个答案:

答案 0 :(得分:1)

如上面的评论中所述,这已在当前版本的Chrome中解决。

相关问题