Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

fix(nuxt): check before appending comma in composable keys - #8529

Merged
pi0 merged 2 commits into
mainfrom
fix/comma-grenade
Nov 2, 2022
Merged

fix(nuxt): check before appending comma in composable keys#8529
pi0 merged 2 commits into
mainfrom
fix/comma-grenade

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/nuxt#15272

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

We were previously not confirming whether there was a trailing comma before appending our own.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroedanielroe added bug Something isn't working 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage labels Oct 27, 2022
@danielroe
danielroe requested a review from pi0October 27, 2022 13:40
@danielroedanielroe self-assigned this Oct 27, 2022
@codesandbox

Copy link
Copy Markdown

CodeSandbox logoCodeSandbox logo Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@netlify

netlifyBot commented Oct 27, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commit4abf359
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/6362431346db760008dfb0c9

break
}

const endsWithComma = code.slice(codeIndex + (node as any).start, codeIndex + (node as any).end - 1).trim().endsWith(',')

@pi0pi0Nov 2, 2022

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perf: this is a heavy operation to run on each code block, copying the whole string, trimming (that also copies) to only check the last character is ,. We could replace it with a look-behind loop.

Suggested change
constendsWithComma=code.slice(codeIndex+(nodeasany).start,codeIndex+(nodeasany).end-1).trim().endsWith(',')
// TODO: Optimize me (https://github.com/nuxt/framework/pull/8529)
constendsWithComma=code.slice(codeIndex+(nodeasany).start,codeIndex+(nodeasany).end-1).trim().endsWith(',')

pi0
pi0 approved these changes Nov 2, 2022
@pi0
pi0 merged commit f485c14 into mainNov 2, 2022
@pi0
pi0 deleted the fix/comma-grenade branch November 2, 2022 10:15
@pi0pi0 mentioned this pull request Nov 3, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xbugSomething isn't working🔨 p3-minor-bugPriority 3: a bug in an edge case that only affects very specific usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useAsyncData with comma breaks

2 participants

@danielroe@pi0