You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by CJRChang <gi...@git.apache.org> on 2015/03/12 02:15:32 UTC
[GitHub] cordova-windows pull request: Fix for callback invocation with NO_...
GitHub user CJRChang opened a pull request:
https://github.com/apache/cordova-windows/pull/61
Fix for callback invocation with NO_RESULT
Due to the enumeration of cordova.callbackStatus (NO_RESULT = 0 and OK = 1), the logic used for defaulting to cordova.callbackStatus.OK will always default to cordova.callbackStatus.OK when the callbackStatus is set to cordova.callbackStatus.NO_RESULT.
This change addresses this issue by first checking if callbackOptions.status is null and defaulting to cordova.callbackStatus.OK, otherwise it will accept the callbackOptions.status value provided by the user.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/CJRChang/cordova-windows patch-1
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/cordova-windows/pull/61.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #61
----
commit 1e4b5330103af18a75dd82772eab3541b6436f19
Author: CJRChang <cj...@users.noreply.github.com>
Date: 2015-03-12T01:14:38Z
Fix for callback invocation with NO_RESULT
Due to the enumeration of cordova.callbackStatus (NO_RESULT = 0 and OK = 1), the logic used for defaulting to cordova.callbackStatus.OK will always default to cordova.callbackStatus.OK when the callbackStatus is set to cordova.callbackStatus.NO_RESULT.
This change addresses this issue by first checking if callbackOptions.status is null and defaulting to cordova.callbackStatus.OK, otherwise it will accept the callbackOptions.status value provided by the user.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-windows pull request: Fix for callback invocation with NO_...
Posted by purplecabbage <gi...@git.apache.org>.
Github user purplecabbage commented on the pull request:
https://github.com/apache/cordova-windows/pull/61#issuecomment-79148007
No, that would/could work also, but I decided to just use the loosely falsey comparison
{{ if (callbackOptions.status != null) ... }}
which is true for both null and undefined. See #62
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-windows pull request: Fix for callback invocation with NO_...
Posted by robpaveza <gi...@git.apache.org>.
Github user robpaveza commented on a diff in the pull request:
https://github.com/apache/cordova-windows/pull/61#discussion_r26281092
--- Diff: cordova-js-src/exec.js ---
@@ -60,18 +60,32 @@ module.exports = function (success, fail, service, action, args) {
// CB-5806 [Windows8] Add keepCallback support to proxy
onSuccess = function (result, callbackOptions) {
callbackOptions = callbackOptions || {};
+ var callbackStatus;
+ if (callbackOptions.status !== null) {
--- End diff --
If the user passed undefined explicitly, it would have evaluated to falsy and in line 65 (pre-change) would have been replaced with cordova.callbackStatus.OK. With your change, line 64's (post-change) test is true (undefined !== null), so local callbackStatus becomes undefined (line 65), and the status property is undefined (line 72 or 88).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-windows pull request: Fix for callback invocation with NO_...
Posted by robpaveza <gi...@git.apache.org>.
Github user robpaveza commented on a diff in the pull request:
https://github.com/apache/cordova-windows/pull/61#discussion_r26400963
--- Diff: cordova-js-src/exec.js ---
@@ -60,18 +60,32 @@ module.exports = function (success, fail, service, action, args) {
// CB-5806 [Windows8] Add keepCallback support to proxy
onSuccess = function (result, callbackOptions) {
callbackOptions = callbackOptions || {};
+ var callbackStatus;
+ if (callbackOptions.status !== null && callbackOptions.status !== undefined) {
--- End diff --
So resolution sounded like if (callbackOptions.hasOwnProperty('status')) ? That ensures that even for falsy values, if they were set, they're propagated through as-is?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
RE: [GitHub] cordova-windows pull request: Fix for callback
invocation with NO_...
Posted by Rob Paveza <Ro...@microsoft.com>.
Only question is if callback.status might be undefined (stands to reason if it can be null). If so, the present check is insufficient and changes because you test with ===.
-Rob
-----Original Message-----
From: robpaveza [mailto:git@git.apache.org]
Sent: Wednesday, March 11, 2015 11:14 PM
To: dev@cordova.apache.org
Subject: [GitHub] cordova-windows pull request: Fix for callback invocation with NO_...
Github user robpaveza commented on a diff in the pull request:
https://github.com/apache/cordova-windows/pull/61#discussion_r26280733
--- Diff: cordova-js-src/exec.js ---
@@ -60,18 +60,32 @@ module.exports = function (success, fail, service, action, args) {
// CB-5806 [Windows8] Add keepCallback support to proxy
onSuccess = function (result, callbackOptions) {
callbackOptions = callbackOptions || {};
+ var callbackStatus;
+ if (callbackOptions.status !== null) {
--- End diff --
Is undefined a possible value here?
---
If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-windows pull request: Fix for callback invocation with NO_...
Posted by robpaveza <gi...@git.apache.org>.
Github user robpaveza commented on a diff in the pull request:
https://github.com/apache/cordova-windows/pull/61#discussion_r26280733
--- Diff: cordova-js-src/exec.js ---
@@ -60,18 +60,32 @@ module.exports = function (success, fail, service, action, args) {
// CB-5806 [Windows8] Add keepCallback support to proxy
onSuccess = function (result, callbackOptions) {
callbackOptions = callbackOptions || {};
+ var callbackStatus;
+ if (callbackOptions.status !== null) {
--- End diff --
Is undefined a possible value here?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-windows pull request: Fix for callback invocation with NO_...
Posted by purplecabbage <gi...@git.apache.org>.
Github user purplecabbage commented on the pull request:
https://github.com/apache/cordova-windows/pull/61#issuecomment-78841786
Hi Ray,
I have created an issue in JIRA for this, thanks for bringing it to my attention.
I have merged your pull request into my own. here: #62
Please have a look and review it.
I removed some of the strict checking as != null will return true for both undefined and null, but not 0
Here's the long form proof ... I also considered using hasOwnProperty
```
// Loose equality
({status:undefined}).status != null // false
({status:undefined}).status != undefined // false
({status:undefined}).status != 0 // true
({status:null}).status != undefined // false
({status:null}).status != null // false
({status:null}).status != 0 // true
({status:0}).status != null // true
({status:0}).status != undefined // true
({status:0}).status != 0 // false
// Strict equality
({status:undefined}).status !== null // true
({status:undefined}).status !== undefined // false
({status:undefined}).status !== 0 // true
({status:null}).status !== null // false
({status:null}).status !== undefined // true
({status:null}).status !== 0 // true
({status:0}).status !== null // true
({status:0}).status !== undefined // true
({status:0}).status !== 0 // false
({status:undefined}).hasOwnProperty('status') // true
({status:null}).hasOwnProperty('status') // true
({status:0}).hasOwnProperty('status') // true
({}).hasOwnProperty('status') // false
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-windows pull request: Fix for callback invocation with NO_...
Posted by CJRChang <gi...@git.apache.org>.
Github user CJRChang commented on the pull request:
https://github.com/apache/cordova-windows/pull/61#issuecomment-78938907
Hi Jesse,
Thanks for raising the issue on JIRA - the changes look great, definitely more elegant than my initial proposal. Thanks for the input!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-windows pull request: Fix for callback invocation with NO_...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/cordova-windows/pull/61
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-windows pull request: Fix for callback invocation with NO_...
Posted by CJRChang <gi...@git.apache.org>.
Github user CJRChang commented on a diff in the pull request:
https://github.com/apache/cordova-windows/pull/61#discussion_r26280804
--- Diff: cordova-js-src/exec.js ---
@@ -60,18 +60,32 @@ module.exports = function (success, fail, service, action, args) {
// CB-5806 [Windows8] Add keepCallback support to proxy
onSuccess = function (result, callbackOptions) {
callbackOptions = callbackOptions || {};
+ var callbackStatus;
+ if (callbackOptions.status !== null) {
--- End diff --
Yes it is - in the event that the user passes a callbackOptions but does not specify status, it will return null.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-windows pull request: Fix for callback invocation with NO_...
Posted by CJRChang <gi...@git.apache.org>.
Github user CJRChang commented on a diff in the pull request:
https://github.com/apache/cordova-windows/pull/61#discussion_r26282196
--- Diff: cordova-js-src/exec.js ---
@@ -60,18 +60,32 @@ module.exports = function (success, fail, service, action, args) {
// CB-5806 [Windows8] Add keepCallback support to proxy
onSuccess = function (result, callbackOptions) {
callbackOptions = callbackOptions || {};
+ var callbackStatus;
+ if (callbackOptions.status !== null) {
--- End diff --
My sincere apologies sir - you're quite right and I've amended the code to handle undefined.
I've evidently been writing too much code in too many languages at once.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org