Skip to content

Commit 7ac0c02

Browse files
committed
Check element existence before attempting to remove
1 parent 8adf130 commit 7ac0c02

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

resources/assets/js/app.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,11 @@ $(function() {
647647
// Trix editor settings
648648
if (typeof Trix === 'object') {
649649
document.addEventListener('trix-initialize', (e) => {
650-
document.querySelector('trix-toolbar .trix-button-group--history-tools').remove();
651-
document.querySelector('trix-toolbar .trix-button-group--file-tools').remove();
650+
const history_tools = document.querySelector('trix-toolbar .trix-button-group--history-tools');
651+
const file_tools = document.querySelector('trix-toolbar .trix-button-group--file-tools');
652+
653+
if (history_tools) history_tools.remove();
654+
if (file_tools) file_tools.remove();
652655
});
653656
document.addEventListener('trix-file-accept', (e) => {
654657
e.preventDefault();

0 commit comments

Comments
 (0)