fix(common): do not warn about missing preconnect hints for same-origin images#68741
Open
kon72 wants to merge 1 commit into
Open
fix(common): do not warn about missing preconnect hints for same-origin images#68741kon72 wants to merge 1 commit into
kon72 wants to merge 1 commit into
Conversation
…in images When the `PreconnectLinkChecker` checks whether an image has a corresponding preconnect hint, it should not log a warning if the image location is the same origin as the page, even if there is no preconnect link, since the browser already establishes a connection to the origin of the page. Also replace the usage of `inject(DOCUMENT).defaultView.location` with `PlatformLocation` for a test with a mocked location.
cc5ab17 to
723790c
Compare
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.
In local development,
PreconnectLinkCheckerchecks whether an priority image has a corresponding preconnect hint and warns in the console if it does not.It should not log a warning if the image location is the same origin as the page, even if there is no preconnect link, since the browser already establishes a connection to the origin of the page and there is no benefit of adding the preconnect hint.
Previously, accessing local development server through a hostname other than
localhost,127.0.0.1,0.0.0.0,[::1], it logs a warning in the browser console despite the same-origin image:Developers can manually provide
PRECONNECT_CHECK_BLOCKLISTto exclude specific origins from the preconnect checks, but IMHO this change gives a sensible default behavior.Also replace the usage of
inject(DOCUMENT).defaultView.locationwithPlatformLocationfor a test with a mocked location.PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
<img ngSrc="assets/foo.png" width="100" height="50" priority>http://localhost:4200https://internal.example.comtohttp://localhost:4200https://internal.example.comNG02956warning in the browser consoleWhat is the new behavior?
It doesn't log the warning.
Does this PR introduce a breaking change?
Other information