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(@tarojs/extend): query 判空&抛出异常 #9328

Closed
wants to merge 13 commits into from
Closed

fix(@tarojs/extend): query 判空&抛出异常 #9328

wants to merge 13 commits into from

Conversation

alexlees
Copy link
Contributor

这个 PR 做了什么? (简要描述所做更改)

对createSelectorQuery 做判空,并在错误时抛出异常

这个 PR 是什么类型? (至少选择一个)

这个 PR 涉及以下平台:

  • 所有小程序
  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 字节跳动小程序
  • QQ 轻应用
  • 京东小程序
  • 快应用平台(QuickApp)
  • Web 平台(H5)
  • 移动端(React-Native)

@alexlees
Copy link
Contributor Author

@luckyadam 能review下吗,很小的点,还没能合并上去

@alexlees
Copy link
Contributor Author

@Chen-jj review please.

@@ -711,8 +711,9 @@ export const Zepto = (function () {
if (!this.length) return null
if (document.documentElement !== this[0] && !$.contains(document.documentElement, this[0])) { return { top: 0, left: 0 } }
if (!isBrowser) {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
Taro.createSelectorQuery().select('#' + this[0].uid).boundingClientRect(function (rect) {
Copy link
Contributor

Choose a reason for hiding this comment

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

boundingClientRect 的回调要用箭头函数

Taro.createSelectorQuery().select('#' + this[0].uid).boundingClientRect(function (rect) {
if (!rect) reject(new Error('offset error: ' + '#' + this[0].uid + ' query fail'))
Copy link
Contributor

Choose a reason for hiding this comment

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

应该直接 return,或者把 resolve 放入 else 块中。现在还是会执行 resolve 的。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Promise A+ 规范会处理reject后的resolve

@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 8, 2021

@alexlees 十分抱歉现在才 review。PR 有两个问题,因为时间久远所有我们来改吧,十分感谢 PR ~

@alexlees
Copy link
Contributor Author

alexlees commented Jul 9, 2021

@alexlees 十分抱歉现在才 review。PR 有两个问题,因为时间久远所有我们来改吧,十分感谢 PR ~

OK,抱歉,被关掉MR后还是有点抱怨,但是看到晚上11点还在为开源做事情还是很感动

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.

2 participants