Skip to content

Commit

Permalink
[#84] Fix checkbox buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
stereobooster committed Jan 1, 2018
1 parent c8c7e09 commit 456a940
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,18 @@ const fixInsertRule = ({ page }) => {
});
};

const fixRadioButtons = ({ page }) => {
const fixRadioCheckboxButtons = ({ page }) => {
return page.evaluate(() => {
Array.from(document.querySelectorAll("[type=radio]")).forEach(radio => {
if (radio.checked) {
radio.setAttribute("checked", "checked");
}
});
Array.from(document.querySelectorAll("[type=checkbox]")).forEach(radio => {
if (radio.checked) {
radio.setAttribute("checked", "checked");
}
});
});
};

Expand Down Expand Up @@ -597,7 +602,7 @@ const run = async userOptions => {
}, ajaxCache[route]);
delete ajaxCache[route];
if (options.fixInsertRule) await fixInsertRule({ page });
await fixRadioButtons({ page });
await fixRadioCheckboxButtons({ page });

const routePath = route.replace(publicPath, "");
const filePath = path.join(destinationDir, routePath);
Expand Down

0 comments on commit 456a940

Please sign in to comment.