MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / syncCheckboxState

Function syncCheckboxState

src/components/searchbar/index.js:225–237  ·  view source on GitHub ↗

* Sync the checked property of checkbox and radio elements, since cloneNode and innerHTML do not copy/preserve dynamic checked state. * @param {HTMLElement} $clone * @param {HTMLElement} $item

($clone, $item)

Source from the content-addressed store, hash-verified

223 * @param {HTMLElement} $item
224 */
225 function syncCheckboxState($clone, $item) {
226 const $itemCheckbox = $item.querySelector(
227 'input[type="checkbox"], input[type="radio"]',
228 );
229 if ($itemCheckbox) {
230 const $cloneCheckbox = $clone.querySelector(
231 'input[type="checkbox"], input[type="radio"]',
232 );
233 if ($cloneCheckbox) {
234 $cloneCheckbox.checked = $itemCheckbox.checked;
235 }
236 }
237 }
238}
239
240export default searchBar;

Callers 2

cloneSearchItemFunction · 0.85
syncSearchCloneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected