Skip to content

Commit

Permalink
fix some no-jquery/no-extend autofixes (wikimedia-gadgets#2088)
Browse files Browse the repository at this point in the history
* revert some no-jquery/no-extend autofixes

Upstream, they caught a bug in the autofix algorithm. Basically, you should only change $.extend() to Object.assign() if you're sure the first argument isn't null or undefined. Else it will throw.

This patch changes a couple back to $.extend, out of an abundance of caution.

wikimedia/eslint-plugin-no-jquery@35d4489

Partial revert of wikimedia-gadgets#2079

* instead of reverting, add `|| {}`
  • Loading branch information
NovemLinguae authored Nov 29, 2024
1 parent d45aaac commit e7d4c6c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion modules/twinkleblock.js
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ Twinkle.block.callback.issue_template = function twinkleblockCallbackIssueTempla
// "talk page" of an IP range (which does not exist)
const userTalkPage = 'User_talk:' + mw.config.get('wgRelevantUserName');

const params = Object.assign(formData, {
const params = Object.assign(formData || {}, {
messageData: Twinkle.block.blockPresetsInfo[formData.template],
reason: Twinkle.block.field_template_options.block_reason,
disabletalk: Twinkle.block.field_template_options.notalk,
Expand Down
2 changes: 1 addition & 1 deletion morebits.js
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ Morebits.quickForm.element.prototype.compute = function QuickFormElementCompute(
node = document.createElement('div');

data.inputs.forEach((subdata) => {
const cell = new Morebits.quickForm.element(Object.assign(subdata, { type: '_dyninput_cell' }));
const cell = new Morebits.quickForm.element(Object.assign(subdata || {}, { type: '_dyninput_cell' }));
node.appendChild(cell.render());
});
if (data.remove) {
Expand Down
2 changes: 1 addition & 1 deletion twinkle.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ $.ajax({
const options = JSON.parse(optionsText);
if (options) {
if (options.twinkle || options.friendly) { // Old preferences format
Twinkle.prefs = Object.assign(options.twinkle, options.friendly);
Twinkle.prefs = Object.assign(options.twinkle || {}, options.friendly);
} else {
Twinkle.prefs = options;
}
Expand Down

0 comments on commit e7d4c6c

Please sign in to comment.