Skip to content

Commit 882bd9d

Browse files
authored
Release - v2.3.4 (#3033)
1 parent adcfe77 commit 882bd9d

File tree

5 files changed

+150
-3
lines changed

5 files changed

+150
-3
lines changed

.github/workflows/pr-create-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ permissions:
88
jobs:
99
comment:
1010
# Don't auto-close actual release PRs
11-
if: ${{github.actor != 'JAForbes' || !contains(github.event.issue.title, "Release - v")}}
11+
if: ${{github.actor != 'JAForbes' || !contains(github.event.issue.title, 'Release - v')}}
1212
uses: MithrilJS/infra/.github/workflows/reject-pr.yml@main
1313
secrets: inherit

render/tests/test-normalizeChildren.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,68 @@ o.spec("normalizeChildren", function() {
5353
])
5454
}).throws(TypeError)
5555
})
56+
o("disallows mixed keys, ending with null", function() {
57+
o(function() {
58+
Vnode.normalizeChildren([
59+
{key: 1},
60+
null,
61+
])
62+
}).throws(TypeError)
63+
})
64+
o("disallows mixed keys, starting with null", function() {
65+
o(function() {
66+
Vnode.normalizeChildren([
67+
null,
68+
{key: 2},
69+
])
70+
}).throws(TypeError)
71+
})
72+
o("disallows mixed keys, ending with undefined", function() {
73+
o(function() {
74+
Vnode.normalizeChildren([
75+
{key: 1},
76+
undefined,
77+
])
78+
}).throws(TypeError)
79+
})
80+
o("disallows mixed keys, starting with undefined", function() {
81+
o(function() {
82+
Vnode.normalizeChildren([
83+
undefined,
84+
{key: 2},
85+
])
86+
}).throws(TypeError)
87+
})
88+
o("disallows mixed keys, ending with false", function() {
89+
o(function() {
90+
Vnode.normalizeChildren([
91+
{key: 1},
92+
false,
93+
])
94+
}).throws(TypeError)
95+
})
96+
o("disallows mixed keys, starting with false", function() {
97+
o(function() {
98+
Vnode.normalizeChildren([
99+
false,
100+
{key: 2},
101+
])
102+
}).throws(TypeError)
103+
})
104+
o("disallows mixed keys, ending with true", function() {
105+
o(function() {
106+
Vnode.normalizeChildren([
107+
{key: 1},
108+
true,
109+
])
110+
}).throws(TypeError)
111+
})
112+
o("disallows mixed keys, starting with true", function() {
113+
o(function() {
114+
Vnode.normalizeChildren([
115+
true,
116+
{key: 2},
117+
])
118+
}).throws(TypeError)
119+
})
56120
})

render/vnode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Vnode.normalizeChildren = function(input) {
1919
for (var i = 1; i < input.length; i++) {
2020
if ((input[i] != null && input[i].key != null) !== isKeyed) {
2121
throw new TypeError(
22-
isKeyed && (input[i] != null || typeof input[i] === "boolean")
22+
isKeyed && (input[i] == null || typeof input[i] === "boolean")
2323
? "In fragments, vnodes must either all have keys or none have keys. You may wish to consider using an explicit keyed empty fragment, m.fragment({key: ...}), instead of a hole."
2424
: "In fragments, vnodes must either all have keys or none have keys."
2525
)

scripts/_bundler-impl.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ module.exports = async (input) => {
6464
const include = /(?:((?:var|let|const|,|)[\t ]*)([\w_$\.\[\]"'`]+)(\s*=\s*))?require\(([^\)]+)\)(\s*[`\.\(\[])?/gm
6565
let uuid = 0
6666
async function process(filepath, data) {
67-
for (const [, binding] of matchAll(data, declaration)) bindings.set(binding, 0)
67+
for (const [, binding] of matchAll(data, declaration)) {
68+
if (!bindings.has(binding)) bindings.set(binding, 0)
69+
}
6870

6971
const tasks = []
7072

@@ -164,6 +166,12 @@ module.exports = async (input) => {
164166
return pre + b.replace(/\d+$/, "") + post
165167
})
166168

169+
// fix comment‑only lines
170+
const commentOnlyLines = /^(?:[ \t]*\/\/[^\r\n]*|[ \t]*\/\*[\s\S]*?\*\/[ \t]*)\r?$/gm
171+
code = code.replace(commentOnlyLines, (comment) =>
172+
comment.replace(variables, (match) => match.replace(/\d+$/, ""))
173+
)
174+
167175
return code
168176
.replace(/("|')use strict\1;?/gm, "") // remove extraneous "use strict"
169177
.replace(/module\.exports\s*=\s*/gm, escapeReplace(rest ? `var _${uuid}` + eq : def + (rest ? "_" : "") + variable + eq)) // export

scripts/tests/test-bundler.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,79 @@ o.spec("bundler", async () => {
293293

294294
o(await bundle(p("a.js"))).equals(";(function() {\nvar b0 = {b: 1}\nvar b = function() {return b0.b}\n}());")
295295
})
296+
o.spec("fix comments", () => {
297+
o("fix /* */ comments", async () => {
298+
await setup({
299+
"a.js": 'var b = require("./b")\nvar c = require("./c")',
300+
"b.js": "var a = 1\nmodule.exports = a",
301+
"c.js": "var a = 2\n/* a */\nmodule.exports = a",
302+
})
303+
304+
o(await bundle(p("a.js"))).equals(";(function() {\nvar a = 1\nvar b = a\nvar a0 = 2\n/* a */\nvar c = a0\n}());")
305+
})
306+
o("fix // comments", async () => {
307+
await setup({
308+
"a.js": 'var b = require("./b")\nvar c = require("./c")',
309+
"b.js": "var a = 1\nmodule.exports = a",
310+
"c.js": "var a = 2\n// a\nmodule.exports = a",
311+
})
312+
313+
o(await bundle(p("a.js"))).equals(";(function() {\nvar a = 1\nvar b = a\nvar a0 = 2\n// a\nvar c = a0\n}());")
314+
})
315+
o("fix multi-line /* */ comments", async () => {
316+
await setup({
317+
"a.js": 'var b = require("./b")\nvar c = require("./c")',
318+
"b.js": "var a = 1\nmodule.exports = a",
319+
"c.js": "var a = 2\n/* \na */\nmodule.exports = a",
320+
})
321+
322+
o(await bundle(p("a.js"))).equals(";(function() {\nvar a = 1\nvar b = a\nvar a0 = 2\n/* \na */\nvar c = a0\n}());")
323+
})
324+
o("does not fix trailing /* */ comments", async () => {
325+
await setup({
326+
"a.js": 'var b = require("./b")\nvar c = require("./c")',
327+
"b.js": "var a = 1\nmodule.exports = a",
328+
"c.js": "var a = 2/* a */\nmodule.exports = a",
329+
})
330+
331+
o(await bundle(p("a.js"))).equals(";(function() {\nvar a = 1\nvar b = a\nvar a0 = 2/* a0 */\nvar c = a0\n}());")
332+
})
333+
o("does not fix trailing // comments", async () => {
334+
await setup({
335+
"a.js": 'var b = require("./b")\nvar c = require("./c")',
336+
"b.js": "var a = 1\nmodule.exports = a",
337+
"c.js": "var a = 2// a\nmodule.exports = a",
338+
})
339+
340+
o(await bundle(p("a.js"))).equals(";(function() {\nvar a = 1\nvar b = a\nvar a0 = 2// a0\nvar c = a0\n}());")
341+
})
342+
o("does not fix trailing multi-line /* */ comments", async () => {
343+
await setup({
344+
"a.js": 'var b = require("./b")\nvar c = require("./c")',
345+
"b.js": "var a = 1\nmodule.exports = a",
346+
"c.js": "var a = 2/* \na */\nmodule.exports = a",
347+
})
348+
349+
o(await bundle(p("a.js"))).equals(";(function() {\nvar a = 1\nvar b = a\nvar a0 = 2/* \na0 */\nvar c = a0\n}());")
350+
})
351+
})
352+
o("prevents double suffixes (mountRedraw00)", async () => {
353+
await setup({
354+
// /index.js (request(b), mount-redraw(z), route(c))
355+
"a.js": 'var b = require("./b")\nvar z = require("./z")\nvar c = require("./c")',
356+
// /request.js
357+
"b.js": 'var z = require("./z")\nmodule.exports = require("./p")(z)',
358+
// /route.js
359+
"c.js": 'var z = require("./z")\nmodule.exports = require("./q")(z)',
360+
// /request/request.js
361+
"p.js": "module.exports = function(z){}",
362+
// /api/router.js
363+
"q.js": "module.exports = function(z){}",
364+
// /mount-redraw.js
365+
"z.js": "module.exports = {}",
366+
})
367+
368+
// check that the argument z2 is not z00
369+
o(await bundle(p("a.js"))).equals(";(function() {\nvar z0 = {}\nvar _1 = function(z1){}\nvar b = _1(z0)\nvar z = z0\nvar _5 = function(z2){}\nvar c = _5(z)\n}());")
370+
})
296371
})

0 commit comments

Comments
 (0)