Skip to content

Commit

Permalink
Wrap script into IIFE to avoid variable naming conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
byStrange committed Aug 15, 2024
1 parent 3c11857 commit c046911
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/DateTimePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private function getScript(): string
$config = json_encode($this->config, JSON_THROW_ON_ERROR);

return <<<JS
const htmlElement = document.querySelector('html');
(function(){const htmlElement = document.querySelector('html');
let theme = htmlElement.getAttribute('data-bs-theme');
const config = JSON.parse('$config');
Expand All @@ -119,7 +119,7 @@ private function getScript(): string
};
}
$("#$this->id").tempusDominus(config);
$("#$this->id").tempusDominus(config);})()
JS;
}

Expand Down

0 comments on commit c046911

Please sign in to comment.