Skip to content

fix(utils): serializeFunction fails with certain functions #8780

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

Merged
merged 5 commits into from
Feb 7, 2021
Merged

fix(utils): serializeFunction fails with certain functions #8780

merged 5 commits into from
Feb 7, 2021

Conversation

rchl
Copy link

@rchl rchl commented Feb 6, 2021

A function shorthand with certain statements inside failed to
serialize properly using serializeFunction.

Resolves #8779

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

The issue was due to the replacement patterns not considering there being
a space between the function name and the parenthesis before the
arguments.

Changed the simple string pattern to regexp to be able to match any
number of whitespace characters between those.

Also changed the test file to not be transformed by babel-jest as that
has affected the input passed to "serializeFunction" and made some tests
invalid. For example, the new test didn't even fail with babel-jest as
it was transforming the test input in a way that made it pass.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.

Sorry, something went wrong.

A function shorthand with certain statements inside failed to
serialize properly using serializeFunction.

The issue was due to the replacement patterns not considering there
being a space between the function name and the parenthesis before the
arguments.

Changed the simple string pattern to regexp to be able to match any
number of whitespace characters between those.

Also changed the test file to not be transformed by babel-jest as that
has affected the input passed to "serializeFunction" and made some tests
invalid. For example, the new test didn't even fail with babel-jest as
it was transforming the test input in a way that made it pass.

Resolves #8779
@codecov-io
Copy link

Codecov Report

Merging #8780 (b0ed202) into dev (fffb1a1) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #8780   +/-   ##
=======================================
  Coverage   66.03%   66.03%           
=======================================
  Files          92       92           
  Lines        4013     4013           
  Branches     1105     1105           
=======================================
  Hits         2650     2650           
  Misses       1097     1097           
  Partials      266      266           
Flag Coverage Δ
unittests 66.03% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/utils/src/serialize.js 87.87% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fffb1a1...b0ed202. Read the comment docs.

rchl and others added 2 commits February 7, 2021 21:25

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pi0 pi0 changed the title fix: serializeFunction helper fails with certain functions fix(utils): serializeFunction fails with certain functions Feb 7, 2021
@pi0 pi0 merged commit d343d85 into nuxt:dev Feb 7, 2021
@rchl rchl deleted the fix/serialize-fn branch February 7, 2021 23:11
@pi0 pi0 mentioned this pull request Feb 9, 2021
@danielroe danielroe added the 2.x label Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fails to serialize certain functions using serializeFunction in the template
4 participants