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

The aop is invalid When the pointcut.target is intanceof Function #9

Closed
GoogleCodeExporter opened this issue Mar 15, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link
Contributor

for exp: jQuery is a Function and jQuery.get can't be intercepted!

$.aop.before({target:jQueryObj,method:"get"},function(invocation){
                        alert("Intercept the method 
get of jQuery !");
                        //return 
invocation.proceed();
                    });

I modify the aop.js in line 88. 
old code: 
var source = (typeof(pointcut.target.prototype) != 'undefined') ? 
pointcut.target.prototype : pointcut.target

new code:
var source = (typeof(pointcut.target) !== 'function' && 
typeof(pointcut.target.prototype) != 'undefined') ? 
pointcut.target.prototype : 
pointcut.target;

Then the bug is fixed!
But the test.case01 gonna be failed.
because String,Function,Number and Date are function in JavaScript

I correct the test.case01 like this :
old code : {target: String, method: 'indexOf' }
new code : {target: String.prototype, method: 'indexOf' }
test.case01 passed and the code is bad smell ^_^

I think using a Array like [Number,Date,String] to recognize the variable 
to be a type constructor function.
If it's true ,the pointcut.target is it's prototype else itself !

Original issue reported on code.google.com by Herist.Z...@gmail.com on 10 Oct 2009 at 3:55

@GoogleCodeExporter
Copy link
Contributor Author

The fix for issue #8 is probably what fixed this, but anyway, I've added a test 
case 
for interception on jQuery.get at r16.
Could you check if the issue is now solved for you? 

Thanks!

Original comment by gonzaloc...@gmail.com on 10 Oct 2009 at 10:39

  • Changed state: NeedInfo

@GoogleCodeExporter
Copy link
Contributor Author

Hi:
I have checked , It can't fix this issue.
In r16 ,you used the $('#XX') as a target.
typeof($('#xx') is a object but $ is a Function,They are different.
When the target is a Function it dosen't work.
Sorry,My English is not good enough!
See the test file!

Original comment by Herist.Z...@gmail.com on 13 Oct 2009 at 2:34

Attachments:

@GoogleCodeExporter
Copy link
Contributor Author

Oh, I see what you mean. I'll work on it.

Original comment by gonzaloc...@gmail.com on 13 Oct 2009 at 8:32

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Contributor Author

Fixed advice on function as target and added test case at r21.

Herist.ZHOU, could you check if this works for you? Thanks!

Original comment by gonzaloc...@gmail.com on 13 Oct 2009 at 7:31

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Contributor Author

Mm... sorry, this not 100% there. It is failing on FF.

Original comment by gonzaloc...@gmail.com on 13 Oct 2009 at 8:04

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Contributor Author

Ok, now I think we are good! :) I've committed some more changes on r22 and 
tested on 
all major browsers (and some minor as well!) and it seems to work properly. 

Could you please confirm it is fine for you? Thanks

Original comment by gonzaloc...@gmail.com on 14 Oct 2009 at 9:33

  • Changed state: Fixed

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

No branches or pull requests

1 participant