dom manipulations uses elements

This commit is contained in:
realaravinth
2021-05-09 16:39:52 +05:30
parent cd729effb9
commit 686774a182
30 changed files with 262 additions and 128 deletions

View File

@@ -53,9 +53,11 @@ const updateLevelNumbersOnDOM = (id: number) => {
}
// rename legend
const legendText = document.createTextNode(`Level ${newLevel}`);
levelGroup.getElementsByTagName(
'legend',
)[0].innerText = `Level ${newLevel}`;
)[0].appendChild(legendText);
// rename labels
updateLabels(levelGroup, newLevel);

View File

@@ -15,7 +15,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import getNumLevels from '../../levels/getNumLevels';
import {getAddForm, trim} from '../../setupTests';
import updateInputs from './updateInputs';
import CONST from '../../const';
@@ -29,7 +28,7 @@ document.body.innerHTML = getAddForm();
log.setMode(MODE.none);
it('addLevelButton works', () => {
it('updateInputs works', () => {
setupAddlevels();
// removing level 2
const level = 2;

View File

@@ -36,7 +36,9 @@ const updateInput = (levelGroup: Element, newLevel: number) => {
input.id = id;
input.name = id;
} else {
throw new Error('Did you add an extra input to DOM?');
if (input.id != 'add') {
throw new Error(`Did you add an extra input to DOM? ${input.id} ${input.className} ${input.name}`);
}
}
});
};