Repository navigation
feat(ImageCropper): support static asset fingerprint - #1160
Merged
Merged
Conversation
- pass cropper.bundle.css url to JS via options.styleUrl - resolve url with Assets helper on .NET 9+ to enable cache busting - replace hard-coded path in addLink call
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe ImageCropper now supplies its stylesheet URL from .NET initialization, using fingerprinted static asset resolution on .NET 9+ and the existing unversioned path on earlier frameworks; JavaScript consumes that URL after confirming the target element exists. Sequence diagram for fingerprinted ImageCropper stylesheet loadingsequenceDiagram
participant Component as ImageCropper
participant Assets as Assets helper
participant JS as ImageCropper JavaScript
participant DOM as Browser DOM
participant CSS as cropper.bundle.css
Component->>Assets: Assets[CropperStylePath]
Assets-->>Component: Fingerprinted styleUrl
Component->>JS: init(id, invoke, options)
JS->>DOM: getElementById(id)
alt target element exists
JS->>CSS: addLink(styleUrl)
CSS-->>DOM: Load stylesheet
else target element missing
JS-->>Component: return
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/components/BootstrapBlazor.ImageCropper/ImageCropper.razor.js" line_range="13" />
<code_context>
const image = el.querySelector(".bb-cropper-image");
- const { options: op, triggerOnCropEndAsync } = options;
+ const { options: op, triggerOnCropEndAsync, styleUrl } = options;
+ await addLink(styleUrl);
if (triggerOnCropEndAsync) {
let cropData = null;
</code_context>
<issue_to_address>
**Removed components retain croppers**
When the component is removed and `dispose(id)` runs while `addLink(styleUrl)` is pending, `dispose(id)` finds no `Data` entry while `addLink(styleUrl)` is pending; `init` then resumes, creates a `Cropper` for the detached element, and stores it in `Data`, retaining the removed component and allowing callbacks through its disposed interop reference.
After `addLink` resolves, have `init` check whether the component was disposed and abort before creating or storing the cropper.
</issue_to_address>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link issues
fixes #1159
Summary By Copilot
ImageCropper loaded
cropper.bundle.cssfrom a hard-coded_contentURL, so the browser kept serving the stale stylesheet after a package upgrade. The stylesheet URL is now passed to JavaScript through the init options and resolved with theAssetsfingerprint helper on .NET 9+, which appends the content hash as a query string. Earlier target frameworks keep the plain path, and the JavaScript side now takes the URL fromoptions.styleUrlinstead of embedding it. The element null check moved ahead of the stylesheet load so a missing container no longer triggers an extra request.Regression?
Risk
Only the stylesheet URL source changed. The markup, component parameters, and public API are untouched, and the non-fingerprint path is preserved for frameworks below .NET 9.
Verification
dotnet build ./src/components/BootstrapBlazor.ImageCropper/BootstrapBlazor.ImageCropper.csproj -c Debugsucceeded for all five target frameworks (net6.0/net7.0/net8.0/net9.0/net10.0) with 0 warnings and 0 errors.Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Enable cache-busted loading of the ImageCropper stylesheet while preserving compatibility with earlier target frameworks.
New Features:
Bug Fixes:
Enhancements:
Build:
Chores: