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(InputItem): add try catch to getSelection (#3236) #3237
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3237 +/- ##
=========================================
+ Coverage 60.07% 60.1% +0.02%
=========================================
Files 92 92
Lines 2282 2286 +4
Branches 656 656
=========================================
+ Hits 1371 1374 +3
- Misses 902 903 +1
Partials 9 9
Continue to review full report at Codecov.
|
|
||
let prePos = 0; | ||
try { | ||
prePos = el.selectionEnd || 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
备注下为啥会异常?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉这样写会比较直观。
try {
prePos = el.selectionEnd;
} catch (e) {
prePos = 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这样子改TS会报错:不能将类型“number | null”分配给类型“number”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
异常的原因注释已加哈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch到错误只是console.warn
么,没有兜底措施吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
兜底就是不处理光标位置了
这个问题改了好几次了的样子。。 |
First of all, thank you for your contribution! :-)
Please makes sure that these checkboxes are checked before submitting your PR, thank you!
npm run lint
and fix those errors before submitting in order to keep consistent code style.Extra checklist:
if isBugFix :
elif isNewFeature :
This change is