@bonniernews/local-esi
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -11,2 +11,7 @@ Changelog | ||
## [2.0.1] - 2021-12-17 | ||
### Fixed | ||
- Removed fallthrough behaviour of overlapping whens | ||
## [2.0.0] - 2021-12-09 | ||
@@ -13,0 +18,0 @@ |
@@ -41,3 +41,3 @@ /* eslint-disable no-use-before-define */ | ||
open(data, next) { | ||
this.context.chooses.push({ hasEvaluatedToTrue: false, isCurrentlyEvaluatedTo: false }); | ||
this.context.chooses.push({ testMatched: false, chosen: false }); | ||
return next(); | ||
@@ -55,3 +55,15 @@ } | ||
const lastChoose = context.chooses[context.chooses.length - 1]; | ||
const result = test(data.test, context); | ||
let result; | ||
try { | ||
result = test(data.test, context); | ||
} catch (err) { | ||
return next(err); | ||
} | ||
if (lastChoose.testMatched) { | ||
lastChoose.chosen = false; | ||
return next(); | ||
} | ||
if (data.matchname) { | ||
@@ -61,4 +73,3 @@ context.assigns[data.matchname] = result; | ||
lastChoose.isCurrentlyEvaluatedTo = !lastChoose.isCurrentlyEvaluatedTo && result; | ||
lastChoose.hasEvaluatedToTrue = lastChoose.hasEvaluatedToTrue || result; | ||
lastChoose.testMatched = lastChoose.chosen = !!result; | ||
@@ -73,3 +84,3 @@ return next(); | ||
const lastChoose = context.chooses[context.chooses.length - 1]; | ||
lastChoose.isCurrentlyEvaluatedTo = !lastChoose.hasEvaluatedToTrue; | ||
lastChoose.chosen = !lastChoose.testMatched; | ||
return next(); | ||
@@ -76,0 +87,0 @@ } |
@@ -50,3 +50,3 @@ "use strict"; | ||
if (this.chooses.length) { | ||
return this.chooses.every((choose) => choose.isCurrentlyEvaluatedTo); | ||
return this.chooses.every((choose) => choose.chosen); | ||
} | ||
@@ -53,0 +53,0 @@ |
{ | ||
"name": "@bonniernews/local-esi", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Local Edge Side Includes parser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
52716
1594
0