Skip to content

Commit

Permalink
Merge pull request #139 from 10up/fix/only-the-first-instance-of-inse…
Browse files Browse the repository at this point in the history
…cure-content-is-fixed

Properly handle fixing of multiple different instances of insecure content
  • Loading branch information
jeffpaul committed Aug 28, 2023
2 parents 625b4f9 + d2f13ab commit 4052423
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/js/gutenberg.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,19 @@ domReady(() => {
if (data === true) {
jQuery(this).nextAll('.js-icw-fixed').show();
replaceContent(url);
// The "check" data has to be removed because otherwise it will always return the URL for the first replaced URL.
// Alternatively "const url = jQuery(clickedButton).data('check');" can be changed to "const url = clickedButton.dataset.check;".
jQuery(this).removeData('check');
} else {
// show the error
jQuery(this).nextAll('.js-icw-error').show();
throw new Error('No https equivalent found.');
}

// The instance of the clicked button will have been lost when the timeout happens, so an instance needs to be kept.
const clickedButton = e.currentTarget;
setTimeout(function () {
jQuery(clickedButton).nextAll('.js-icw-fixed').hide();
gutenbergCheck(e);
}, 1000);
},
Expand Down Expand Up @@ -169,6 +175,9 @@ domReady(() => {
'js-icw-is-insecure'
);
}

// The "check" data has to be removed because otherwise it will always return the URL for the first highlighted URL.
jQuery(this).removeData('check');
}
});
});

0 comments on commit 4052423

Please sign in to comment.