Skip to content

correction when nodeOps.tagName returns value other than string #11332

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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

andrehrferreira
Copy link

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

@posva
Copy link
Member

posva commented Apr 21, 2020

Can you provide a reproduction of the bug you are fixing?

@@ -5899,7 +5899,7 @@ function createPatchFunction (backend) {
}

function emptyNodeAt (elm) {
return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
return (typeof nodeOps.tagName(elm) == "string") ? new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm) : new VNode("", {}, [], undefined, elm)

Choose a reason for hiding this comment

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

could be rewritten as

Suggested change
return (typeof nodeOps.tagName(elm) == "string") ? new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm) : new VNode("", {}, [], undefined, elm)
return new VNode((typeof nodeOps.tagName(elm) == "string") ? nodeOps.tagName(elm).toLowerCase() : '', {}, [], undefined, elm)

@andrehrferreira
Copy link
Author

andrehrferreira commented Apr 22, 2020 via email

@andrehrferreira
Copy link
Author

https://ibb.co/hMZ0XrM

@posva
Copy link
Member

posva commented Apr 22, 2020

I understand you are trying to fix a problem you find in your code but I'm asking you for a boiled down reproduction or at the very least a test case that fails without the proposed change. Otherwise, we won't be able to accept the change

You can use https://jsfiddle.net/chrisvfritz/50wL7mdz/ or https://codesandbox.io/s/vue to create a boiled down reproduction (no extra dependencies like Nuxt)

BTW dist and packages files are generated and should be excluded from the PR.

@andrehrferreira
Copy link
Author

andrehrferreira commented Apr 22, 2020 via email

@posva
Copy link
Member

posva commented Apr 22, 2020

The reproduction is essential to understand if this is the right fix or not. The problem could be elsewhere leading to tagName not being a string.
Either way, a unit test is also required for bug fixes.
This will stay open for anybody to pick up

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

Successfully merging this pull request may close these issues.

3 participants