Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 2986a09

Browse files
committedDec 5, 2011
fix(jqLite): JQLiteHasClass should work even when minified
closure compiler is smarter than we expected and drops the unused fn argument - this breaks the meta-programing logic of jqLite. The fix special cases JQLiteHasClass since its the only fn that needs this treatment in a way that is minification-proof.
1 parent bb2e748 commit 2986a09

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎src/jqLite.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ function JQLiteData(element, key, value) {
219219
}
220220
}
221221

222-
function JQLiteHasClass(element, selector, _) {
223-
// the argument '_' is important, since it makes the function have 3 arguments, which
224-
// is needed for delegate function to realize the this is a getter.
222+
function JQLiteHasClass(element, selector) {
225223
return ((" " + element.className + " ").replace(/[\n\t]/g, " ").
226224
indexOf( " " + selector + " " ) > -1);
227225
}
@@ -427,7 +425,9 @@ forEach({
427425
JQLite.prototype[name] = function(arg1, arg2) {
428426
var i, key;
429427

430-
if ((fn.length == 2 ? arg1 : arg2) === undefined) {
428+
// JQLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it
429+
// in a way that survives minification.
430+
if (((fn.length == 2 && fn !== JQLiteHasClass) ? arg1 : arg2) === undefined) {
431431
if (isObject(arg1)) {
432432
// we are a write, but the object properties are the key/values
433433
for(i=0; i < this.length; i++) {

0 commit comments

Comments
 (0)