Skip to content

Update image.astro#3

Open
Momciloo wants to merge 2 commits intomainfrom
fix/load-bcms-img-client-side
Open

Update image.astro#3
Momciloo wants to merge 2 commits intomainfrom
fix/load-bcms-img-client-side

Conversation

@Momciloo
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Astro image component to ensure the bcms-image custom element behavior is available in the browser by loading its module at runtime.

Changes:

  • Import ./image.ts as a URL for runtime loading.
  • Inject a <script type="module" ...> tag before rendering <bcms-image>.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<>
<script
type="module"
set:html={`if (typeof window !== 'undefined' && 'customElements' in window && !customElements.get('bcms-image')) { import('${imageModuleUrl}'); }`}
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline module script is injected via set:html, which introduces an inline-script requirement that can be blocked by strict Content-Security-Policy (no unsafe-inline). To keep this component usable in CSP-restricted apps (and reduce per-image script duplication), prefer loading the web component via an external module script (src pointing at the built URL) or require consumers to import/register the element once at the app/layout level.

Suggested change
set:html={`if (typeof window !== 'undefined' && 'customElements' in window && !customElements.get('bcms-image')) { import('${imageModuleUrl}'); }`}
src={imageModuleUrl}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bbanez check if this is acceptable

@Momciloo Momciloo requested a review from Bbanez March 30, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants