Skip to content

Commit

Permalink
prevent changing descriptor object in defineProperty wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed May 13, 2015
1 parent a4e9e35 commit 7dc41f5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion library/modules/es6.symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function defineProperty(it, key, D){
it[HIDDEN][key] = true;
} else {
if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
D.enumerable = false;
D = $create(D, {enumerable: desc(0, false)});
}
} return setDesc(it, key, D);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/es6.symbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function defineProperty(it, key, D){
it[HIDDEN][key] = true;
} else {
if(has(it, HIDDEN) && it[HIDDEN][key])it[HIDDEN][key] = false;
D.enumerable = false;
D = $create(D, {enumerable: desc(0, false)});
}
} return setDesc(it, key, D);
}
Expand Down
8 changes: 5 additions & 3 deletions tests/tests-library.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tests/tests-library/es6.symbol.ls
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ if descriptors
defineProperty O, \b, value: \b
defineProperty O, \c, value: \c, enumerable: on
defineProperty O, e, configurable: on, writable:on, value: \e
defineProperty O, f, value: \f, enumerable: on
desc = value: \f, enumerable: on
defineProperty O, f, desc
eq desc.enumerable, on, 'defineProperty not changes descriptor object'
deq getOwnPropertyDescriptor(O, \a), {configurable: on, writable:on, enumerable: on, value: \a}, 'getOwnPropertyDescriptor a'
deq getOwnPropertyDescriptor(O, \b), {configurable: no, writable:no, enumerable: no, value: \b}, 'getOwnPropertyDescriptor b'
deq getOwnPropertyDescriptor(O, \c), {configurable: no, writable:no, enumerable: on, value: \c}, 'getOwnPropertyDescriptor c'
Expand Down
8 changes: 5 additions & 3 deletions tests/tests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tests/tests/es6.symbol.ls
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ if descriptors
defineProperty O, \b, value: \b
defineProperty O, \c, value: \c, enumerable: on
defineProperty O, e, configurable: on, writable:on, value: \e
defineProperty O, f, value: \f, enumerable: on
desc = value: \f, enumerable: on
defineProperty O, f, desc
eq desc.enumerable, on, 'defineProperty not changes descriptor object'
deq getOwnPropertyDescriptor(O, \a), {configurable: on, writable:on, enumerable: on, value: \a}, 'getOwnPropertyDescriptor a'
deq getOwnPropertyDescriptor(O, \b), {configurable: no, writable:no, enumerable: no, value: \b}, 'getOwnPropertyDescriptor b'
deq getOwnPropertyDescriptor(O, \c), {configurable: no, writable:no, enumerable: on, value: \c}, 'getOwnPropertyDescriptor c'
Expand Down

0 comments on commit 7dc41f5

Please sign in to comment.