Katochimoto/xblocks

View on GitHub
src/utils/resetLastRadioChecked.js

Summary

Maintainability
A
0 mins
Test Coverage
const CHECKED_CACHE = {};

/**
 * FIXME don't work cloneNode
 * @param {HTMLElement} element
 * @param {string} name
 */
export default function (element, name) {
    name = String(name);
    const lastCheckedElement = CHECKED_CACHE[ name ];

    if (lastCheckedElement && lastCheckedElement !== element) {
        lastCheckedElement.checked = false;
    }

    CHECKED_CACHE[ name ] = element;
}