enketo-transformer
Advanced tools
Comparing version 1.41.2 to 1.41.3
@@ -5,2 +5,7 @@ ## Change Log | ||
[1.41.3] - 2020-12-21 | ||
------------------------ | ||
##### Fixed | ||
- If the same repeat question has both a setvalue/odk-instance-first-load as well as a setvalue/xforms-value-changed, the output can get messed up. | ||
[1.41.2] - 2020-11-18 | ||
@@ -7,0 +12,0 @@ ------------------------ |
{ | ||
"name": "enketo-transformer", | ||
"version": "1.41.2", | ||
"version": "1.41.3", | ||
"description": "Library/app that transforms ODK-compliant XForms into a format that Enketo can consume", | ||
@@ -49,4 +49,4 @@ "license": "Apache-2.0", | ||
"docdash": "^1.2.0", | ||
"eslint": "^7.13.0", | ||
"eslint-plugin-jsdoc": "^30.7.8", | ||
"eslint": "^7.16.0", | ||
"eslint-plugin-jsdoc": "^30.7.9", | ||
"http-server": "^0.12.3", | ||
@@ -53,0 +53,0 @@ "istanbul-reporter-shield-badge": "^1.2.1", |
@@ -168,3 +168,3 @@ /** | ||
const name = setValueEl.attr( 'name' ).value(); | ||
const questionSameName = doc.get( `//*[@name="${name}" and contains(../@class, 'question')]` ); | ||
const questionSameName = doc.get( `//*[@name="${name}" and contains(../@class, 'question') and not(@type='hidden')]` ); | ||
if ( questionSameName ) { | ||
@@ -171,0 +171,0 @@ //console.log( 'question with same name', setValueEl.parent().attr( 'class' ).value() ); |
@@ -17,3 +17,3 @@ const chai = require( 'chai' ); | ||
const elements = Array.prototype.slice.call( htmlDoc.getElementsByTagName( tagName ) ); | ||
const target = elements.find( el => el.getAttribute( 'name' ) === nameAttributeValue ); | ||
const target = elements.find( el => el.getAttribute( 'name' ) === nameAttributeValue ); | ||
@@ -780,2 +780,22 @@ return target || null; | ||
} ); | ||
it( 'with a dynamic default repeat question, that also gets its value set by a trigger', () => { | ||
const xform = fs.readFileSync( './test/forms/setvalue-repeat-tricky.xml', 'utf8' ); | ||
const transform = transformer.transform( { xform } ).then( parseHtmlForm ); | ||
return transform | ||
.then( form => { | ||
const ages = findElementsByName( form, 'input', '/data/person/group/age' ); | ||
expect( ages.length ).to.equal( 2 ); | ||
const agePrimary = ages[1]; // actual form control shown in form | ||
const ageHidden = ages[0]; // hidden setvalue/xforms-value-changed directive | ||
expect( agePrimary.getAttribute( 'data-event' ) ).to.equal( 'odk-new-repeat odk-instance-first-load' ); | ||
expect( agePrimary.getAttribute( 'data-setvalue' ) ).to.equal( '100' ); | ||
expect( ageHidden.getAttribute( 'data-event' ) ).to.equal( 'xforms-value-changed' ); | ||
expect( ageHidden.getAttribute( 'data-setvalue' ) ).to.equal( '15' ); | ||
} ); | ||
} ); | ||
} ); | ||
@@ -782,0 +802,0 @@ } ); |
Sorry, the diff of this file is not supported yet
5687466
103
3128