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

$.fn.scope undefined when using CommonJS #1288

Closed
ccummings opened this Issue Oct 27, 2014 · 4 comments

Comments

Projects
None yet
4 participants
@ccummings
Contributor

ccummings commented Oct 27, 2014

I'm using CanJS in a Browserify application and noticed the scope jQuery plugin is not defined.

This happens because can.Component checks if window.$ is defined before adding the plugin but in a CommonJS environment, jQuery does not add $ to window.

Source: https://github.com/bitovi/canjs/blob/master/component/component.js#L423

I think a much safer check would be window.jQuery since that always seems to be exposed.

@ccummings ccummings self-assigned this Oct 27, 2014

@daffl daffl added this to the 2.1.4 milestone Oct 27, 2014

@Macrofig Macrofig assigned Macrofig and unassigned ccummings Nov 4, 2014

@daffl daffl added the bug label Nov 5, 2014

@daffl daffl closed this in #1311 Nov 6, 2014

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Jan 14, 2015

Contributor

I am using browserify too and just noticed this problem. I think the correct solution would be to check for can.$.fn

Contributor

justinbmeyer commented Jan 14, 2015

I am using browserify too and just noticed this problem. I think the correct solution would be to check for can.$.fn

@Macrofig

This comment has been minimized.

Show comment
Hide comment
@Macrofig

Macrofig Jan 14, 2015

Contributor

I thought the solution was to not do this at all and, instead, have the check for jQuery abstracted from can.component. Or are you saying to use can.$.fn in the mean time?

Contributor

Macrofig commented Jan 14, 2015

I thought the solution was to not do this at all and, instead, have the check for jQuery abstracted from can.component. Or are you saying to use can.$.fn in the mean time?

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Jan 14, 2015

Contributor

I mean if(can.$.fn) { can.$.fn = function{ ... } }

But people can use $().scope()

Contributor

justinbmeyer commented Jan 14, 2015

I mean if(can.$.fn) { can.$.fn = function{ ... } }

But people can use $().scope()

@justinbmeyer

This comment has been minimized.

Show comment
Hide comment
@justinbmeyer

justinbmeyer Jan 14, 2015

Contributor

Basically, we shouldn't be checking for jQuery. If can.$ is an interface to the underlying library's nodeList. Perhaps can.$.fn should be its interface to adding additional methods to it.

Contributor

justinbmeyer commented Jan 14, 2015

Basically, we shouldn't be checking for jQuery. If can.$ is an interface to the underlying library's nodeList. Perhaps can.$.fn should be its interface to adding additional methods to it.

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