|
576 | 576 | } |
577 | 577 | catch (e) { |
578 | 578 |
|
579 | | - throw "[ ERROR ] " + e |
580 | | - + " In parsing position: " + it.position + " '" + it.current + "' => " |
| 579 | + throw ": In parsing position: " + it.position + " '" + it.current + "' => " |
581 | 580 | + it.text.substring(it.position < 10 ? 0 : it.position - 10, it.position + 10) |
582 | 581 | .replace(/\r/g, "\\r") |
583 | | - .replace(/\n/g, "\\n"); |
| 582 | + .replace(/\n/g, "\\n") |
| 583 | + + "\n" + e.message + e.stack; |
584 | 584 | } |
585 | 585 |
|
586 | 586 | _setMetadata(value, meta); |
|
671 | 671 |
|
672 | 672 | function _get(val, def) { |
673 | 673 |
|
674 | | - if (it.current === '\r' && it.following === '\r') { |
675 | | - |
676 | | - if (!def._isDataContext) { |
677 | | - |
678 | | - def = createDataContext(def); |
679 | | - def._isModified = true; |
680 | | - } |
681 | | - if (_typeof(val) === 'array') { |
682 | | - |
683 | | - val.length = 0; |
684 | | - } |
685 | | - if (val?._events) { def._events = val._events; } |
686 | | - if (val?._propertyName && val._parent) { |
687 | | - |
688 | | - def._parent = val._parent; |
689 | | - def._propertyName = val._propertyName; |
690 | | - val._parent[val._propertyName] = def; |
691 | | - } |
692 | | - |
693 | | - it.next(); |
694 | | - it.next(); |
695 | | - |
696 | | - return def; |
697 | | - } |
698 | | - else if (_typeof(val) !== _typeof(def)) { |
| 674 | + if (_typeof(val) !== _typeof(def)) { |
699 | 675 |
|
700 | 676 | if (val?._isDataContext) { |
701 | 677 |
|
|
914 | 890 |
|
915 | 891 | it.next(); |
916 | 892 |
|
| 893 | + var isNewObject = it.current === '\r' && it.following === '\r', |
| 894 | + keys = []; |
| 895 | + |
| 896 | + if (isNewObject) { |
| 897 | + |
| 898 | + it.next(); |
| 899 | + it.next(); |
| 900 | + } |
| 901 | + |
917 | 902 | var obj = _get(val, {}); |
918 | 903 |
|
919 | 904 | _setMetadata(obj, meta); |
|
937 | 922 |
|
938 | 923 | var k = _key(); |
939 | 924 |
|
| 925 | + keys.push(k); |
| 926 | + |
940 | 927 | _whitespace(); |
941 | 928 |
|
942 | 929 | var v = _value(obj[k] || val?.[k]); |
|
1003 | 990 | it.next(); |
1004 | 991 | } |
1005 | 992 |
|
| 993 | + if (isNewObject) { |
| 994 | + |
| 995 | + for (var k of Object.keys(obj)) { |
| 996 | + |
| 997 | + if (!keys.includes(k)) { |
| 998 | + |
| 999 | + delete obj[k]; |
| 1000 | + obj._isModified = true; |
| 1001 | + } |
| 1002 | + } |
| 1003 | + } |
| 1004 | + |
1006 | 1005 | return obj; |
1007 | 1006 | } |
1008 | 1007 | } |
|
1040 | 1039 |
|
1041 | 1040 | it.next(); |
1042 | 1041 |
|
| 1042 | + var isNewArray = it.current === '\r' && it.following === '\r'; |
| 1043 | + |
| 1044 | + if (isNewArray) { |
| 1045 | + |
| 1046 | + it.next(); |
| 1047 | + it.next(); |
| 1048 | + } |
| 1049 | + |
1043 | 1050 | var arr = _get(val, []); |
1044 | 1051 |
|
1045 | 1052 | _setMetadata(arr, meta); |
|
1142 | 1149 | it.next(); |
1143 | 1150 | } |
1144 | 1151 |
|
| 1152 | + if (isNewArray && val?.length > i) { |
| 1153 | + |
| 1154 | + val.length = i; |
| 1155 | + arr._isModified = true; |
| 1156 | + } |
| 1157 | + |
1145 | 1158 | return arr; |
1146 | 1159 | } |
1147 | 1160 | } |
|
0 commit comments