Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Wrapper function doesn't return orignal function's result #667

Closed
zzx88991 opened this issue Mar 9, 2017 · 4 comments · Fixed by #682
Closed

Wrapper function doesn't return orignal function's result #667

zzx88991 opened this issue Mar 9, 2017 · 4 comments · Fixed by #682

Comments

@zzx88991
Copy link
Contributor

zzx88991 commented Mar 9, 2017

I am using ASP.NET Webform (yeah, it is legacy code..) with <asp:UpdatePanel> and <AsyncPostBackTrigger>.
When a button click triggers a async postback, event.onsubmit from <form onsubmit="javascript:return WebForm_OnSubmit();"> will be called and return the validation result. However it is not returned once zone.js wraps the event handler, resulting the request not passing validation.

The source code here shows that the wrapper function doesn't return the result of
https://github.com/angular/zone.js/blob/master/lib/common/utils.ts#L89

const wrapFn = function(event) {
        let result;
        result = fn.apply(this, arguments);

        if (result != undefined && !result) event.preventDefault();
};

Not sure what it the purpose of this code not returning result. Thanks for taking a look.

@zzx88991 zzx88991 changed the title Wrapper function doesn't return validation result Wrapper function doesn't return orignal function's result Mar 9, 2017
@JiaLiPassion
Copy link
Collaborator

@zzx88991 , thank you for posting the issue, I will make a PR to fix it.

@JiaLiPassion
Copy link
Collaborator

@zzx88991 , I have further question about this one, I am not familiar with ASP.NET, current zone.js implementation just call event.preventDefault when eventHandler return false, so in your code, the form will not submit but you will directly use the eventHandler return value somewhere else, is that right?

@zzx88991
Copy link
Contributor Author

Yes, you are right. The eventHandler is called somewhere else before the the form is submitted. I am just curious why wrapFun doesn't return result

@JiaLiPassion
Copy link
Collaborator

@zzx88991 , yes, it should return , I just want to create test case to prove it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants