mirror of
https://github.com/tc39/test262.git
synced 2025-07-13 09:04:36 +02:00
Improve isEnumerable check with a for-in loop for string names (#880)
Ref https://github.com/tc39/test262/pull/879#discussion_r104128520
This commit is contained in:
parent
6c20a250f2
commit
866d7f8d8e
@ -11,7 +11,22 @@ function isConfigurable(obj, name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isEnumerable(obj, name) {
|
function isEnumerable(obj, name) {
|
||||||
return Object.prototype.hasOwnProperty.call(obj, name) &&
|
var stringCheck;
|
||||||
|
|
||||||
|
if (typeof name === "string") {
|
||||||
|
for (var x in obj) {
|
||||||
|
if (x === name) {
|
||||||
|
stringCheck = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// skip it if name is not string, works for Symbol names.
|
||||||
|
stringCheck = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringCheck &&
|
||||||
|
Object.prototype.hasOwnProperty.call(obj, name) &&
|
||||||
Object.prototype.propertyIsEnumerable.call(obj, name);
|
Object.prototype.propertyIsEnumerable.call(obj, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user