diff --git a/src/ui/ElementStyler.js b/src/ui/ElementStyler.js
index fd8515d..4ee28cc 100644
--- a/src/ui/ElementStyler.js
+++ b/src/ui/ElementStyler.js
@@ -833,7 +833,7 @@ module.exports = Class( 'ElementStyler',
if ( filter )
{
- throw new Error( "Filter deprecated" );
+ throw new Error( 'Filter deprecated' );
}
return this._jquery( results );
@@ -855,7 +855,7 @@ module.exports = Class( 'ElementStyler',
if ( hasindex )
{
var id = this._getElementId( name, index );
-
+
if ( id )
{
element = document.getElementById( id );
@@ -1045,11 +1045,25 @@ module.exports = Class( 'ElementStyler',
},
+ /**
+ * Determines the id of an element based on the type
+ *
+ * @param {string} name element name
+ * @param {number} index index of element to retrieve (bucket index)
+ *
+ * @return {string} element id
+ */
'private _getElementId': function( name, index )
{
switch ( this._getElementType( name ) )
{
- case 'radio': return '';
+ case 'radio':
+ return '';
+ case 'answer':
+ return name;
+ case 'checkbox':
+ name += '_n';
+ break;
case 'noyes':
// append yes/no depending on whether or not the given index is
// even/odd
@@ -1057,13 +1071,11 @@ module.exports = Class( 'ElementStyler',
? '_y'
: '_n';
- index = index / 2;
-
- /* fallthrough */
-
- default:
- return 'q_' + name + '_' + index;
+ index = Math.floor( index / 2 );
+ break;
}
+
+ return 'q_' + name + '_' + index;
},
diff --git a/test/ui/ElementStylerTest.js b/test/ui/ElementStylerTest.js
new file mode 100644
index 0000000..e7d16af
--- /dev/null
+++ b/test/ui/ElementStylerTest.js
@@ -0,0 +1,150 @@
+/**
+ * Test case for ElementStyler
+ *
+ * Copyright (C) 2010-2020 R-T Specialty, LLC.
+ *
+ * This file is part of the Liza Data Collection Framework
+ *
+ * Liza is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see