Skip to content

Commit

Permalink
Fix eslint and bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
mattolson committed Jan 8, 2019
1 parent dcc5585 commit b47d030
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"import/no-named-as-default": 0,
"import/no-named-as-default-member": 0
},
"globals": {
"$": true,
"jQuery": true
},
"env": {
"es6": true,
"browser": true
Expand Down
48 changes: 25 additions & 23 deletions assets/js/theme/global/jquery-migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,32 @@
//
// See https://stackoverflow.com/questions/37738732/jquery-3-0-url-indexof-error/37915907#37915907
//
jQuery.each( [ "load", "unload", "error" ], function( _, name ) {
/* eslint-disable prefer-rest-params */
jQuery.each(['load', 'unload', 'error'], (_, name) => {
const oldLoad = jQuery.fn.load;

jQuery.fn[ name ] = function() {
var args = Array.prototype.slice.call( arguments, 0 );
jQuery.fn[name] = function handler() {
const args = Array.prototype.slice.call(arguments, 0);

// If this is an ajax load() the first arg should be the string URL;
// technically this could also be the "Anything" arg of the event .load()
// which just goes to show why this dumb signature has been deprecated!
// jQuery custom builds that exclude the Ajax module justifiably die here.
if ( name === "load" && typeof args[ 0 ] === "string" ) {
return oldLoad.apply( this, args );
}
// If this is an ajax load() the first arg should be the string URL;
// technically this could also be the "Anything" arg of the event .load()
// which just goes to show why this dumb signature has been deprecated!
// jQuery custom builds that exclude the Ajax module justifiably die here.
if (name === 'load' && typeof args[0] === 'string') {
return oldLoad.apply(this, args);
}

args.splice( 0, 0, name );
if ( arguments.length ) {
return this.on.apply( this, args );
}
args.splice(0, 0, name);
if (arguments.length) {
return this.on.apply(this, args);
}

// Use .triggerHandler here because:
// - load and unload events don't need to bubble, only applied to window or image
// - error event should not bubble to window, although it does pre-1.7
// See http://bugs.jquery.com/ticket/11820
this.triggerHandler.apply( this, args );
return this;
};

} );
// Use .triggerHandler here because:
// - load and unload events don't need to bubble, only applied to window or image
// - error event should not bubble to window, although it does pre-1.7
// See http://bugs.jquery.com/ticket/11820
this.triggerHandler.apply(this, args);
return this;
};
});
/* eslint-enable prefer-rest-params */
3 changes: 0 additions & 3 deletions webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ module.exports = merge(commonConfig, {
mode: 'production',
optimization: {
noEmitOnErrors: true,
splitChunks: {
chunks: 'all',
},
},
});

0 comments on commit b47d030

Please sign in to comment.