Skip to content

Commit d9782b0

Browse files
committed
no condition needed for else
1 parent c7f5fe1 commit d9782b0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

renderIf.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ renderIf.multi = function () {
2727
}
2828
}
2929

30+
function elseCondition (elemOrThunk) {
31+
cases.push({
32+
priority: 2,
33+
condition: true,
34+
elemOrThunk
35+
});
36+
37+
return api;
38+
}
39+
3040
function evaluate() {
3141
let sortedCases = cases.sort((a, b) => a.priority > b.priority);
3242

@@ -45,7 +55,7 @@ renderIf.multi = function () {
4555
const api = {
4656
if: createCondition(0),
4757
elseIf: createCondition(1),
48-
else: createCondition(2),
58+
else: elseCondition,
4959
evaluate
5060
};
5161

0 commit comments

Comments
 (0)