Skip to content

Input type is removed and breaks css #323

@devRoemer

Description

@devRoemer
  • Operating System: Windows
  • Node Version: 12.18.3
  • NPM Version: 6.3.0
  • webpack Version: 4.44.1
  • html-loader Version: >= 1.2.0 (tested also with 1.3.0)

Expected Behavior

Inputs like this are not changed:

<input type="text" name="test">

Actual Behavior

Type text is removed because it is browser default:

<input name="test">

Code

Webpack-Config-Snippet

            {
                test: /\.html$/,
                loader: 'html-loader',
                exclude: /(node_modules)/,
                options: {
                    attributes: {
                        list: [
                            { tag: 'img', attribute: 'src', type: 'src' },
                            { tag: 'img', attribute: 'data-srcset-1x', type: 'srcset' },
                            { tag: 'img', attribute: 'data-srcset-2x', type: 'srcset' },
                        ]
                    }
                }
            },

Full config: https://justpaste.it/4xbub

How Do We Reproduce?

Use this default minimizer settings or the snippet above:

            {
                test: /\.html$/,
                loader: 'html-loader',
                exclude: /(node_modules)/,
                options: {
                    minimize: {
                      caseSensitive: true,
                      collapseWhitespace: true,
                      conservativeCollapse: true,
                      keepClosingSlash: true,
                      minifyCSS: true,
                      minifyJS: true,
                      removeComments: true,
                      removeRedundantAttributes: true,
                      removeScriptTypeAttributes: true,
                      removeStyleLinkTypeAttributes: true,
                    },
                    attributes: {
                        list: [
                            { tag: 'img', attribute: 'src', type: 'src' },
                            { tag: 'img', attribute: 'data-srcset-1x', type: 'srcset' },
                            { tag: 'img', attribute: 'data-srcset-2x', type: 'srcset' },
                        ]
                    }
                }
            },

Add CSS:

input[type=text] {
    border: 1px solid red;
}

Result: The css gets ignored due to the removal of the type attribute.

Change removeRedundantAttributes to false.
Result: The input type is kept as it is and the css is still applied.

Remarks

The behaviour has changed with Version 1.2.0 and the following commit:
03152b1

Also see: #35

Maybe removeRedundantAttributes should be disabled again. If not there should be a hint that there is a breaking change in the Changelog of version 1.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions