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

fix missing spaces in RichText #5116

Merged
merged 8 commits into from Aug 16, 2019

Conversation

@Marssssssss
Copy link
Contributor

commented Aug 7, 2019

Re: cocos-creator/2d-tasks#1646

Changes:

  • delete values which are got by trim() on variables 'text' and 'sText'
  • change functions substr() to substring() in function fragmentText
Marssssssss added 2 commits Aug 7, 2019
no need to add equal sign
add code comments before using substring
Marssssssss added 3 commits Aug 9, 2019
make meaning of parameter fuzzyLen easier to understand
@Marssssssss

This comment has been minimized.

Copy link
Contributor Author

commented Aug 15, 2019

因为单词换行需要向前缩进,左边的空格需要去除,同时因为在处理带标签文本的时候会单独提取出来,导致带标签文本前面的空格会算在之前的字符串段内,在执行 trim() 的时候会删除掉空格串,所以这里将 trim() 改为了 trimLeft() ,并在 polyfill 中添加了某些不兼容该方法的浏览器对该方法的兼容。

has made code style better

if (!String.prototype.trimLeft) {
String.prototype.trimLeft = function () {
return this.replace(/^\s+/g, '');

This comment has been minimized.

Copy link
@jareguo

jareguo Aug 16, 2019

Contributor

这里不需要 /g 吧?

This comment has been minimized.

Copy link
@Marssssssss

Marssssssss Aug 16, 2019

Author Contributor

这里不需要 /g 吧?

这里的语义只匹配一次确实不需要 /g

This comment has been minimized.

Copy link
@Marssssssss

Marssssssss Aug 16, 2019

Author Contributor

这里不需要 /g 吧?

已修改

no need of 'g'
@jareguo jareguo merged commit 69e3b3b into cocos-creator:v2.1.3 Aug 16, 2019
1 check passed
1 check passed
ci/circleci: test Your tests passed on CircleCI!
Details
jareguo added a commit that referenced this pull request Aug 16, 2019
* commit 'aa5ddf4e74f014c2b5f066539136f8c25e7f8326':
  optimize bezier calculation (#5155)
  fix missing spaces in RichText (#5116)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.