AS3 字典 setPropertyIsEnumerable 被忽略
有人可以向我解释为什么 Dictionary 类忽略 setPropertyIsEnumerable 吗?
我在 bugs.adobe 上发现这个 bug,似乎原型可能涉及某些狡猾的方式
这是一些测试代码:
var obj:Object = {
'a': 0,
'b': 1,
'c': 2
}
obj.setPropertyIsEnumerable('a', false)
trace("object\n")
for (var op:* in obj)
{
trace(op)
}
var dict:Dictionary = new Dictionary()
dict['a'] = 0
dict['b'] = 1
dict['c'] = 2
dict.setPropertyIsEnumerable('a', false)
trace("dictionary\n")
for (var dp:* in dict)
{
trace(dp)
}
输出是:
object
c
b
dictionary
c
a
b
请注意,字典仍然枚举属性“a”,即使它被告知不要这样做。
Can someone explain to me why the Dictionary class ignores setPropertyIsEnumerable?
I found this bug at bugs.adobe, seems the prototype might be involved in some devious way
Here is some test code:
var obj:Object = {
'a': 0,
'b': 1,
'c': 2
}
obj.setPropertyIsEnumerable('a', false)
trace("object\n")
for (var op:* in obj)
{
trace(op)
}
var dict:Dictionary = new Dictionary()
dict['a'] = 0
dict['b'] = 1
dict['c'] = 2
dict.setPropertyIsEnumerable('a', false)
trace("dictionary\n")
for (var dp:* in dict)
{
trace(dp)
}
Output of this is:
object
c
b
dictionary
c
a
b
Notice that the Dictionary is still enumerating the property "a" even though it was told not to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是我的猜测...
Dictionary
正在重写nextName
以返回字典的键。它使用自己的实现,因此忽略了setPropertyIsEnumerable。我还不能证明这一点,但我正在努力。我想我应该抛弃这个假设,看看它是否会引发什么。
Here is my guess...
Dictionary
is overridingnextName
in order to return the keys of the dictionary. It is using it's own implementation of it such that it is ignoringsetPropertyIsEnumerable
.I can't prove it yet, but I am trying. I thought I would throw out this hypothesis to see if it sparks anything.