Skip to content

[fix] text nodes are not updated when repeated word is present #5940

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

Closed
wants to merge 6 commits into from

Conversation

suxin2017
Copy link
Contributor

@suxin2017 suxin2017 commented Jan 29, 2021

issuse 5931

export function set_data(text, data) {
	data = '' + data;
// In this case
// here. 
// WholeText is going to be equal to Hello World and the data is going to be the same
// what is wholeText ?
	if (text.wholeText !== data) text.data = data;
}
export function set_data_dev(text, data) {
	data = '' + data;
	if (text.textContent === '' && text.wholeText !== '') {
		if (text.wholeText === data) return;
	} else {
		if (text.textContent === data) return;
	}

	dispatch_dev('SvelteDOMSetData', { node: text, data });
	text.data = data;
}

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with npm test and lint the project with npm run lint

@dummdidumm
Copy link
Member

Could you add a test that fails without the fix?

@Conduitry Conduitry marked this pull request as draft January 29, 2021 15:21
@suxin2017
Copy link
Contributor Author

您能否添加一个没有修复失败的测试?

here is online bug

I added a test case for testing

@suxin2017 suxin2017 marked this pull request as ready for review January 30, 2021 01:21
@Mlocik97
Copy link
Contributor

Mlocik97 commented Feb 14, 2021

I'm not sure if this fix will fix that bug, because well, you can have empty space at end or start of string that You interpolate. If it's adding just " " to NODE. But from code, I would said that's not exactly what You do.

So problem can be if Node contain for example:

"    text"

and you interpolate same string, after that string to NODE.
We propably need something to mark position where interpolated string in NODE start and where it end, or do some advanced comparision.

@benmccann benmccann changed the title fix: same-text-no-update [fix] text nodes are not updated when repeated word is present Jul 23, 2021
@Conduitry Conduitry marked this pull request as draft September 15, 2021 20:20
@vercel
Copy link

vercel bot commented Mar 2, 2023

@dummdidumm is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

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 this pull request may close these issues.

4 participants