-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Conversation
@luckyadam 能review下吗,很小的点,还没能合并上去 |
@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) { |
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.
boundingClientRect 的回调要用箭头函数
Taro.createSelectorQuery().select('#' + this[0].uid).boundingClientRect(function (rect) { | ||
if (!rect) reject(new Error('offset error: ' + '#' + this[0].uid + ' query fail')) |
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.
应该直接 return,或者把 resolve 放入 else 块中。现在还是会执行 resolve 的。
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.
Promise A+ 规范会处理reject后的resolve
@alexlees 十分抱歉现在才 review。PR 有两个问题,因为时间久远所有我们来改吧,十分感谢 PR ~ |
OK,抱歉,被关掉MR后还是有点抱怨,但是看到晚上11点还在为开源做事情还是很感动 |
这个 PR 做了什么? (简要描述所做更改)
对createSelectorQuery 做判空,并在错误时抛出异常
这个 PR 是什么类型? (至少选择一个)
这个 PR 涉及以下平台: