openrosa-xpath-evaluator
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -6,5 +6,10 @@ Change Log | ||
[2.0.0] - 2012-12-22 | ||
[2.0.1] - 2021-01-07 | ||
------------------------ | ||
##### Fixed | ||
- Lazy and/or evaluation within function arguments. | ||
[2.0.0] - 2020-12-22 | ||
----------------------- | ||
##### Added | ||
- Full support for XPath as included in the ODK XForms Spec (when used in Enketo Core). |
{ | ||
"name": "openrosa-xpath-evaluator", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Wrapper for browsers' XPath evaluator with added support for OpenRosa extensions.", | ||
"homepage": "https://enketo.org", | ||
"main": "src/openrosa-xpath.js", | ||
"keywords": [ | ||
"enketo", | ||
"OpenRosa", | ||
"ODK", | ||
"XForms", | ||
"XPath" | ||
], | ||
"scripts": { | ||
@@ -23,3 +30,3 @@ "lint": "eslint --ignore-path .gitignore .", | ||
"chai": "^4.2.0", | ||
"eslint": "^7.16.0", | ||
"eslint": "^7.17.0", | ||
"karma": "^5.2.3", | ||
@@ -26,0 +33,0 @@ "karma-chrome-launcher": "^3.1.0", |
@@ -190,8 +190,8 @@ const { handleOperation } = require('./utils/operation'); | ||
evalOps = function(lastOp) { | ||
const tokens = peek().tokens; | ||
const { tokens } = peek(); | ||
if(peek().dead) for(let i=2; i<tokens.length; ++i) { | ||
if(tokens[i] === D) { | ||
tokens.splice(i-1); | ||
tokens[i-2] = { t:'bool', v:asBoolean(tokens[i-2]) }; | ||
if(peek().dead) { | ||
if(tokens[2] === D) { | ||
const nextComma = tokens.indexOf(','); | ||
tokens.splice(0, nextComma === -1 ? tokens.length : nextComma, { t:'bool', v:asBoolean(tokens[0]) }); | ||
} | ||
@@ -198,0 +198,0 @@ } |
@@ -32,3 +32,39 @@ const { initDoc, assertStringValue } = require('../helpers'); | ||
}); | ||
it(`should evaluate an "and" expression that checks values of nodes (1)`, () => { | ||
const node = doc.getElementById('FunctionChecklistCase0'); | ||
assertStringValue(node, null, 'if(. != "0" and /div/div[@id="FunctionCheckListCaseEmpty"] != "", "yes", "no")', 'no'); | ||
}); | ||
it(`should evaluate an "and" expression that checks values of nodes (2)`, () => { | ||
const node = doc.getElementById('FunctionChecklistCase0'); | ||
assertStringValue(node, null, 'if(. = "0" and /div/div[@id="FunctionCheckListCaseEmpty"] != "", "yes", "no")', 'no'); | ||
}); | ||
it(`should evaluate an "and" expression that checks values of nodes (3)`, () => { | ||
const node = doc.getElementById('FunctionChecklistCase0'); | ||
assertStringValue(node, null, 'if(. = "0" and /div/div[@id="FunctionChecklistCaseNo"] ="no", "yes", "no")', 'yes'); | ||
}); | ||
it(`should evaluate an "or" expression that checks values of nodes (1)`, () => { | ||
const node = doc.getElementById('FunctionChecklistCase0'); | ||
assertStringValue(node, null, 'if(. != "0" or /div/div[@id="FunctionCheckListCaseEmpty"] != "", "yes", "no")', 'no'); | ||
}); | ||
it(`should evaluate an "or" expression that checks values of nodes (2)`, () => { | ||
const node = doc.getElementById('FunctionChecklistCase0'); | ||
assertStringValue(node, null, 'if(. = "0" or /div/div[@id="FunctionCheckListCaseEmpty"] != "", "yes", "no")', 'yes'); | ||
}); | ||
it(`should evaluate an "or" expression that checks values of nodes (3)`, () => { | ||
const node = doc.getElementById('FunctionChecklistCase0'); | ||
assertStringValue(node, null, 'if(. != "0" or /div/div[@id="FunctionChecklistCaseNo"] ="no", "yes", "no")', 'yes'); | ||
}); | ||
it(`should evaluate true and false outcomes`, () => { | ||
const node = doc.getElementById('FunctionChecklistCase0'); | ||
assertStringValue(node, null, 'if(false(), "yes", concat(/div/div[@id="FunctionChecklistCaseNo"], "-no"))', 'no-no'); | ||
}); | ||
}); | ||
}); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
353884
8607
0