question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing type="text" on inputs in prerendered HTML-files

See original GitHub issue

Describe the bug On input fields in prerendered HTML-files, the type attribute is missing if it has the default value “text”. Strangely this is not happening when testing directly with the “preact-render-to-string” package in this CodeSandbox example.

But it happens when I prerender the same content with preact build.

To Reproduce

  1. Prerender a file with an input with type="text" in it.
  2. Check the prerendered index.html file, the type attribute should be gone

Expected behavior The type="text" attribute should not be stripped away, even though it is the default value. It might for example be used for CSS styling.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rschristiancommented, Dec 29, 2021

Sorry for the super late response!

This is intentional, redundant attributes are stripped by html-webpack-plugin (which uses html-minifier-terser to do this).

If you want to disable this, you can use your config file to do so:

preact.config.js

export default (config, env, helpers) => {
    if (env.isProd) {
        const HtmlPlugin = helpers.getPluginsByName(config, 'HtmlWebpackPlugin')[0];
        if (HtmlPlugin) {
            const pluginOptions = HtmlPlugin.plugin.options;
            pluginOptions.minify.removeRedundantAttributes = false;
        }
    }
}
0reactions
roydigerhundcommented, Jul 14, 2021

@developit If --no-inline-css completely disables Critters, then it has nothing to do with it. I already disabled inline CSS in the project where I stumbled upon this bug and I tested it in the example repository too, sadly it didn’t resolve the issue.

type="Text" and Type="text" are also getting stripped away.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changing an Input value in Blazor by javascript doesn't ...
Apparently changing <input> value or any other changes in DOM by javascript doesn't change State, so blazor won't re-render the component.
Read more >
Using Vue.js with Server Rendered Form Input Values
But Vue.js isn't so great for forms with input values already rendered from the server. We'll look at how to get around that...
Read more >
chrome/browser/autofill/autofill_browsertest.cc - chromium/src - Git ...
Navigate to the form, input values into the fields, and submit the form. // The function returns after the PersonalDataManager is updated.
Read more >
Knockout pre-rendered binding handlers - GitHub
This library adds two new binding handlers to Knockout that allow observables to be initialized from pre-rendered HTML content:.
Read more >
Binding syntax - Angular
Angular binding distinguishes between HTML attributes and DOM properties. ... When the browser renders <input type="text" value="Sarah"> , it creates a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found