Skip to content

Commit

Permalink
Prevent empty string from being passed to getElementById() when the r…
Browse files Browse the repository at this point in the history
…oute does not have own templateId

- Improved the logic to ensure `route.templateTargetId` is valid before calling `getElementById()`.
- Added a fallback to `PineconeRouter.settings.templateTargetId` if `route.templateTargetId` is not provided.
- This fix ensures that the correct template target is retrieved, preventing potential runtime errors.
  • Loading branch information
Aramics authored Aug 5, 2024
1 parent 4a1828a commit 4d8a492
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ export default function (Alpine) {

// show templates added programmatically
if (route.template && route.programmaticTemplate) {
let target = document.getElementById(route.templateTargetId) ?? document.getElementById(PineconeRouter.settings.templateTargetId)
let target = route.templateTargetId ? document.getElementById(route.templateTargetId) : document.getElementById(PineconeRouter.settings.templateTargetId);
if (cachedTemplates[route.template]) {
target.innerHTML = cachedTemplates[route.template]
endLoading()
Expand Down

0 comments on commit 4d8a492

Please sign in to comment.