Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5.5.0 contains breaking change with type attribute having undefined value #1710

Closed
StephanBijzitter opened this issue Dec 6, 2021 · 3 comments · Fixed by #1809
Closed

Comments

@StephanBijzitter
Copy link

Current behaviour 💣

When using a custom template (and injecting tags/attributes manually), v5.5.0 has introduced a breaking change where the "type" attribute can be present with a value of undefined. In my case, this result in the rendering of type="undefined", preventing all scripts from being loaded by the browser.

htmlWebpackPlugin.tags.bodyTags[0].attributes
// {type: undefined, otherStuff: ...}

Expected behaviour ☀️

Like v5.4.0: attributes with an undefined value should not be present in the attributes object.

htmlWebpackPlugin.tags.bodyTags[0].attributes
// {otherStuff: ...}

Reproduction Example 👾

Not applicable.

Environment 🖥

  • v5.4.0 is okay
  • v5.5.0 is the first version to have undefined values
@StephanBijzitter
Copy link
Author

I've added:

Object.entries(attributes)
        .filter(([key, val]) => val !== undefined)
        ... rest of code

to my template for now, as that's easy enough, but I do believe this should be addressed in v5.5.1

@jantimon
Copy link
Owner

jantimon commented Dec 7, 2021

Oh thanks for the input - I guess that's from this change: 1e42625

type: options.scriptLoading === 'module' ? 'module' : undefined,

could be changed to a spread logic:

  ...( options.scriptLoading === 'module' ? { type: 'module' } : {})

@StephanBijzitter
Copy link
Author

That would definitely work :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants