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

h5.ajax()の戻り値からpromiseオブジェクトを作ってpromise.fail()でハンドラを登録すると、failハンドラが登録されているのにajaxの通信に失敗時にcommonFailHandlerが動作する #202

Closed
fukudayasuo opened this issue May 15, 2013 · 3 comments
Assignees
Labels
Milestone

Comments

@fukudayasuo
Copy link

var p = h5.ajax('hoge').promise();
p.fail(function(){}); // failハンドラを登録

// commonFailHnandlerが設定してあれば、実行されてしまう。

h5.ajax().promise()は、jqXHRオブジェクトのpromise()の戻り値を返すため、そこでコールバックを登録されたときFW側で判定できていない。

promise()メソッドをオーバーライドし、h5.async.deferred()を使って生成したpromiseオブジェクトを返すようにする。

@ghost ghost assigned fukudayasuo May 15, 2013
@fukudayasuo
Copy link
Author

comit 37e1209
対応しました。
テストケースは未追加です。

fukudayasuo pushed a commit to hifive-labs/hifivemain that referenced this issue May 16, 2013
@fukudayasuo
Copy link
Author

h5.ajax.jsの修正で対応しましたが、この件についてはdfd.promise !== promise().promiseであることも原因の1つでした。
h5.async.jsも合わせて修正します。

dfd = h5.async.deferred();
p=dfd.promise();
p.promise === dfd.promise;
// falseになる。dfd.promiseはh5でラップしたものだが、p.promiseがjQueryのものそのままにになっている
};

h5.ajaxでは、jqXHRWrapperにdfd.promiseではなくdfd.promise().promiseを追加していたため、挙動がおかしくなっていました。dfd.promisedfd.promise().promiseは同じになるようにして対応します。

fukudayasuo pushed a commit to hifive-labs/hifivemain that referenced this issue May 16, 2013
@simdy simdy closed this as completed May 20, 2013
@fukudayasuo
Copy link
Author

05638e6
test/h5.async.jsに本件をテストするテストケースを追加しました。

@simdy simdy reopened this May 20, 2013
@simdy simdy closed this as completed May 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants