You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -422,18 +422,10 @@ class Template extends TemplateContent {
422
422
423
423
returnmergedData;
424
424
}catch(e){
425
-
if(
426
-
ReservedData.isReservedDataError(e)||
427
-
(einstanceofTypeError&&
428
-
e.message.startsWith("Cannot add property")&&
429
-
e.message.endsWith("not extensible"))
430
-
){
431
-
thrownewEleventyBaseError(
432
-
`You attempted to set one of Eleventy’s reserved data property names${e.reservedNames ? `: ${e.reservedNames.join(", ")}` : ""}. You can opt-out of this behavior with \`eleventyConfig.setFreezeReservedData(false)\` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. \`eleventy\`, \`pkg\`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/`,
433
-
e,
434
-
);
425
+
// if ReservedDataError, defer to that (from ReservedData.checkSubset above)
`You attempted to set one of Eleventy’s reserved data property names${reservedNames ? `: ${reservedNames.join(", ")}` : ""}${sourceLocation ? ` (source: ${sourceLocation})` : ""}. You can opt-out of this behavior with \`eleventyConfig.setFreezeReservedData(false)\` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. \`eleventy\`, \`pkg\`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/`,
Copy file name to clipboardExpand all lines: test/EleventyTest.js
+5-11Lines changed: 5 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -965,7 +965,7 @@ eleventy:
965
965
message: 'You attempted to set one of Eleventy’s reserved data property names. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/'
966
966
});
967
967
968
-
t.is(e.originalError.toString(),"TypeError: Cannot add property key1, object is not extensible");
968
+
t.is(e.cause.toString(),"TypeError: Cannot add property key1, object is not extensible");
969
969
});
970
970
971
971
test("Eleventy setting reserved data throws error (pkg)",async(t)=>{
@@ -983,7 +983,7 @@ pkg:
983
983
message: 'You attempted to set one of Eleventy’s reserved data property names. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/'
984
984
});
985
985
986
-
t.is(e.originalError.toString(),"TypeError: Cannot add property myOwn, object is not extensible");
986
+
t.is(e.cause.toString(),"TypeError: Cannot add property myOwn, object is not extensible");
987
987
});
988
988
989
989
test("Eleventy pagination works okay with reserved data throws (eleventy) Issue #3262",async(t)=>{
@@ -1020,8 +1020,6 @@ page: "My page value"
1020
1020
lete=awaitt.throwsAsync(()=>elev.toJSON(),{
1021
1021
message: 'You attempted to set one of Eleventy’s reserved data property names: page. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/'
test("Eleventy setting reserved data throws error (content)",async(t)=>{
@@ -1034,11 +1032,9 @@ content: "My page value"
1034
1032
});
1035
1033
elev.disableLogger();
1036
1034
1037
-
lete=awaitt.throwsAsync(()=>elev.toJSON(),{
1035
+
awaitt.throwsAsync(()=>elev.toJSON(),{
1038
1036
message: 'You attempted to set one of Eleventy’s reserved data property names: content. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/'
test("Eleventy setting reserved data throws error (collections)",async(t)=>{
@@ -1051,11 +1047,9 @@ collections: []
1051
1047
});
1052
1048
elev.disableLogger();
1053
1049
1054
-
lete=awaitt.throwsAsync(()=>elev.toJSON(),{
1050
+
awaitt.throwsAsync(()=>elev.toJSON(),{
1055
1051
message: 'You attempted to set one of Eleventy’s reserved data property names: collections. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/'
test("Eleventy setting pkg data is okay when pkg is remapped to parkour",async(t)=>{
@@ -1143,7 +1137,7 @@ parkour:
1143
1137
message: 'You attempted to set one of Eleventy’s reserved data property names. You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/'
1144
1138
});
1145
1139
1146
-
t.is(e.originalError.toString(),"TypeError: Cannot add property myOwn, object is not extensible");
1140
+
t.is(e.cause.toString(),"TypeError: Cannot add property myOwn, object is not extensible");
1147
1141
});
1148
1142
1149
1143
test("Eleventy data schema (success) #879",async(t)=>{
message: 'You attempted to set one of Eleventy’s reserved data property names: page (source: ./test/stubs-virtual/eleventy.config.js). You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/'
41
+
});
42
+
});
43
+
44
+
test("Eleventy freeze data set via config API throws error (eleventy)",async(t)=>{
message: 'You attempted to set one of Eleventy’s reserved data property names: eleventy (source: ./test/stubs-virtual/eleventy.config.js). You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/'
56
+
});
57
+
});
58
+
59
+
test("Eleventy freeze data set global data file throws error (page)",async(t)=>{
60
+
letelev=newEleventy({
61
+
input: "./test/stubs-freeze/page/",
62
+
config: eleventyConfig=>{
63
+
eleventyConfig.addTemplate("index.html",``);
64
+
}
65
+
});
66
+
elev.disableLogger();
67
+
68
+
awaitt.throwsAsync(()=>elev.toJSON(),{
69
+
message: 'You attempted to set one of Eleventy’s reserved data property names: page.url (source: ./test/stubs-freeze/page/_data/page.js). You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/'
70
+
});
71
+
});
72
+
73
+
test("Eleventy freeze data set global data file throws error (eleventy)",async(t)=>{
74
+
letelev=newEleventy({
75
+
input: "./test/stubs-freeze/eleventy/",
76
+
config: eleventyConfig=>{
77
+
eleventyConfig.addTemplate("index.html",``);
78
+
}
79
+
});
80
+
elev.disableLogger();
81
+
82
+
awaitt.throwsAsync(()=>elev.toJSON(),{
83
+
message: 'You attempted to set one of Eleventy’s reserved data property names: eleventy (source: ./test/stubs-freeze/eleventy/_data/eleventy.js). You can opt-out of this behavior with `eleventyConfig.setFreezeReservedData(false)` or rename/remove the property in your data cascade that conflicts with Eleventy’s reserved property names (e.g. `eleventy`, `pkg`, and others). Learn more: https://v3.11ty.dev/docs/data-eleventy-supplied/'
0 commit comments