]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
[Easy] Don't enumerate momentProperties with 'in'
authorBill Schaller <billschaller@fb.com>
Wed, 8 Mar 2017 19:03:30 +0000 (14:03 -0500)
committerIskren Chernev <iskren.chernev@gmail.com>
Sat, 11 Mar 2017 23:33:32 +0000 (01:33 +0200)
Because of the way many polyfill libraries modify Array.prototype (without Object.defineProperty), enumerating momentProperties with for...in is unsafe.

This is a zero-cost change that makes this enumeration safe.

src/lib/moment/constructor.js

index 83f83effe5c0892d9b6abdcb5b2580ae30fb3249..bc53f814fcda507cb7a59e6ff1bd832822fb8934 100644 (file)
@@ -42,7 +42,7 @@ export function copyConfig(to, from) {
     }
 
     if (momentProperties.length > 0) {
-        for (i in momentProperties) {
+        for (i = 0; i < momentProperties.length; i++) {
             prop = momentProperties[i];
             val = from[prop];
             if (!isUndefined(val)) {