Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openrosa-xpath-evaluator

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openrosa-xpath-evaluator - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

7

CHANGELOG.md

@@ -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",

10

src/extended-xpath.js

@@ -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');
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc