Skip to content

Commit

Permalink
Merge pull request #85 from stereobooster/fix-radios
Browse files Browse the repository at this point in the history
[#84] Fix radio buttons
  • Loading branch information
stereobooster authored Jan 1, 2018
2 parents b181b2d + 13d931b commit ee92185
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ const preloadResources = opt => {
const json = await response.json();
ajaxCache[route] = json;
} else if (http2PushManifest && /\.(js)$/.test(responseUrl)) {
const fileName = url.parse(responseUrl).pathname.split("/").pop();
const fileName = url
.parse(responseUrl)
.pathname.split("/")
.pop();
if (!ignoreForPreload.includes(fileName)) {
http2PushManifestItems.push({
link: route,
Expand Down Expand Up @@ -389,6 +392,16 @@ const fixInsertRule = ({ page }) => {
});
};

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

const saveAsHtml = async ({ page, filePath, options, route }) => {
let content = await page.content();
content = content.replace(/react-snap-onload/g, "onload");
Expand Down Expand Up @@ -584,6 +597,7 @@ const run = async userOptions => {
}, ajaxCache[route]);
delete ajaxCache[route];
if (options.fixInsertRule) await fixInsertRule({ page });
await fixRadioButtons({ page });

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

0 comments on commit ee92185

Please sign in to comment.