-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Compiled Dart JS in combination with jQuery causes TypeError: Cannot call method 'apply' of undefined #2265
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
Comments
This comment was originally written by off...@mikemitterer.at OK, you are right. It's probably Dart2JS. Are you forwarding this ticket to Dart2JS or do I have to do that? |
I ran into this bug again trying to get js.dart + jQuery to work together: https://github.com/dart-lang/js-interop/issues/21 |
Refiled on dart2js. It appears that both dart2js generated code and jquery use a global '$' symbol in incompatible ways. Removed Area-UI label. |
cc @ErikCorryGoogle. |
Issue #6853 has been merged into this issue. |
This comment was originally written by shyc2...@gmail.com I get both dart2js and jQuery working by calling jQuery.noConflict(). It releases the $ symbol which is causing the conflict. |
This comment was originally written by theme...@gmail.com Will this issue be fixed in dart2js? It's annoying when use libraries depend on jQuery, |
Added TriageForM5 label. |
cc @peter-ahe-google. |
We should definitely try to avoid introducing global names. For possible work arounds, take a look at: http://learn.jquery.com/using-jquery-core/avoid-conflicts-other-libraries/ Some of the techniques suggested in that document could also be used by dart2js. |
I needed to clean up how we access $ in some helper methods, so I added an option to control the name of $ to help me test it. https://codereview.chromium.org/16135004 adds option --global-js-name to dart2js. Added Started label. |
Fixed in r23391. Added Fixed label. |
This comment was originally written by kholbr...@sonardesign.com This is still a problem with the build from 23799. |
kholbrook, what is, in your opinion, a correct fix? |
This comment was originally written by kholbr...@sonardesign.com Do not abuse "$". |
Ideally, dart2js should generate code wrapped in something like this: !function($) { Unfortunately, we discovered that this had an adverse effect on performance. Fortunately, the V8 team has since been working on fixing this issue, and we hope to be able to completely eliminate the use of global variables. For now, offering an option is the best we can do. |
This comment was originally written by kholbr...@sonardesign.com In the interim, would it be possible to make the default "$dart"? |
This issue was originally filed by off...@mikemitterer.at
What steps will reproduce the problem?
1.
pull little sample app from git@github.com:MikeMitterer/SampleEventHandling.git
2.
Open the html-File with Fireforx or Chrom - not with Chromium
3.
Click on "Dart rocks" - works
Click on "JQuery rolls" - it fails
Open the Developer Tools in Chrome and you'll see the error message:
Uncaught TypeError: Cannot call method 'apply' of undefined
What is the expected output? What do you see instead?
It's expected that "Dart rocks" add a dot to the 17 and "JQuery rolls" should add
add a ~ to the numer but only the Dart-Part works.
What version of the product are you using? On what operating system?
Version 0.1.0.201203152021, Build 5549
Dart SDK version 5549, Dartium version
JQuery 1.7
MAC
Please provide any additional information below.
The currious thing it that it works in Chromium
Attachment:
screenshot-976.jpg (149.71 KB)
The text was updated successfully, but these errors were encountered: