Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

.noConflict() compliance: only reference $, not jQuery, inside the closure #26

Merged
merged 1 commit into from

2 participants

@jgoldberg

According to the jQuery coding standards (http://wiki.jqueryui.com/w/page/12137737/Coding-standards), you shouldn't reference 'jQuery' inside the closure, only '$':

.noConflict() compliance

Wrap plugins in a closure that passes jQuery in as a parameter. Inside the closure, only reference jQuery through the parameter variable.

(function( $ ) {
// inside here only reference $, not jQuery
}( jQuery ) );

@jeromeetienne

Can you explain the reasoning behind ? Why using jQuery is an issue ?

@jgoldberg

Couple of examples for why you need noConflict() mode:

1) Not everyone can override $ with jQuery in their web applications. For example, people who have a legacy Prototype dependency, but want to use some jQuery features. So some people can only rely on jQuery('.item') instead of $('.item').

2) If you are writing a third-party library that uses jQuery, but the site that may be adding your library also might have their own jQuery implementation. So you need $ and MyLib.$ to coexist.

@jeromeetienne jeromeetienne merged commit 2d05056 into jeromeetienne:master
@jeromeetienne

my bad, i first read the patch on my phone. my bad :)

merged, thanks for contributing!

@jgoldberg

No problem, thanks for the plugin!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  src/jquery.qrcode.js
View
2  src/jquery.qrcode.js
@@ -83,7 +83,7 @@
return this.each(function(){
var element = options.render == "canvas" ? createCanvas() : createTable();
- jQuery(element).appendTo(this);
+ $(element).appendTo(this);
});
};
})( jQuery );
Something went wrong with that request. Please try again.