Commit graph

31 commits

Author SHA1 Message Date
arturovt
7600bec71d fix(router): handle scrollRestoration error in restricted environments (#62186)
In this commit, setting `window.history.scrollRestoration` is wrapped in a try-catch block to prevent `SecurityError` exceptions in restricted contexts such as:

- sandboxed iframes
- partially navigated or inactive windows
- test runners, extensions, or content previews

If an error occurs, a runtime warning with error code [2400] is logged to the console. This avoids breaking app initialization and improves cross-browser safety.

Unfortunately, it's not possible to perform any end-to-end testing of this fix.

PR Close #62186
2025-06-24 12:24:43 +00:00
arturovt
ad5fbd944d refactor(common): drop value not a number message in production (#60699)
Drops value not a number message in production.

PR Close #60699
2025-04-02 19:20:11 +00:00
arturovt
5317979738 refactor(common): drop error messages in production (#60415)
Drops more error messages in production.

PR Close #60415
2025-03-31 18:08:37 +00:00
arturovt
3602c536e4 refactor(common): drop error messages in production (#60242)
Drops more error messages in production.

PR Close #60242
2025-03-10 10:04:03 -07:00
arturovt
0f3fa5a2af refactor(common): drop ngIf assert template error in production (#59705)
This commit removes the `assertTemplate` error message in production.

PR Close #59705
2025-03-05 14:42:18 -08:00
Stephen Hicks
74cceba587 feat(common): throw error for suspicious date patterns (#59798)
Adjusts the date pipe and formatDate function to detect suspicious usages of the week-numbering year formatter without including the week number, as this is often confused for the calendar year and likely to result in incorrect results near New Years, meaning that those issues aren't typically caught during development. This commit starts throwing a development-only error to reveal this issue right away.

BREAKING CHANGE:

Using the `Y` formatter (week-numbering year) without also including `w` (week number) is now detected as suspicious date pattern, as `y` is typically intended.

PR Close #59798
2025-02-24 17:15:03 -05:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Matthieu Riegler
f407e3ce6f refactor(common): allow string urls in NgOptimizedImage input (#54901)
With this commit it is now possible to pass an url as placeholder for the image directive.

PR Close #54901
2024-07-01 18:13:24 +00:00
Matthieu Riegler
cc4cb9608a refactor(common): Log a warning when the priority attribute of NgOptimizedImage is used too often. (#56669)
When the DOM content is loaded, Angular will log a warning message if the `priority` attribute is applied to often on `NgOptimizedImage` directive instances.

PR Close #56669
2024-06-26 12:43:00 -07:00
Alex Castle
f5c520b836 feat(common): add placeholder to NgOptimizedImage (#53783)
Add a automatic placeholder implementation supporting loader-based and data URL placeholders

PR Close #53783
2024-01-29 16:00:38 +00:00
Pawel Kozlowski
28a5925f53 fix(common): use === operator to match NgSwitch cases (#51504)
This change adjust the equality comparator used by NgSwitch - now it
defaults to === from previously used ==. This change is based on the
following reasoning:
- align behaviour with the built-in switch block);
- improve performance (avoid type coercion);
- enable better type-checking.

BREAKING CHANGE:

the NgSwitch directive now defaults to the === equality operator,
migrating from the previously used ==. NgSwitch expressions and / or
individual condition values need adjusting to this stricter equality
check. The added warning message should help pinpointing NgSwitch
usages where adjustements are needed.

Fixes #33873

PR Close #51504
2023-10-09 10:10:21 -07:00
Alex Castle
1837efb9da feat(common): Allow ngSrc to be changed post-init (#50683)
Remove thrown error when ngSrc is modified after an NgOptimizedImage image is initialized

PR Close #50683
2023-07-11 08:30:49 -07:00
Matthieu Riegler
5fd4bf6651 refactor(http): tree-shakable error on JSONP request (#50376)
This commit provides a tree shakable error message (+doc) when JSONP request is made without loading the `HttpClientJsonpModule`.

PR Close #50376
2023-05-24 13:58:49 +00:00
Alex Castle
54b24eb40f feat(common): Add loaderParams attribute to NgOptimizedImage (#48907)
Add a new loaderParams attribute, which can be used to send arbitrary data to a custom loader, allowing for greater control of image CDN features.

PR Close #48907
2023-02-06 10:10:44 -08:00
Iván Navarro
a055196c55 fix(common): warn if using ngSrcset without a configured image loader (#48804)
Warn the user in the console in case the `ngSrcset` is present and no
loader is configured. In this case, the default loader is used and
it ignores this attribute.

PR Close #48804
2023-01-25 19:27:00 +00:00
Kara Erickson
ce5880f93f fix(common): warn if using supported CDN but not built-in loader (#47330)
This commit adds a missing warning if the image directive
detects that you're hosting your image on one of our
supported image CDNs but you're not using the built-in loader
for it. This excludes applications that are using a custom
loader.

PR Close #47330
2022-10-19 15:21:51 +02:00
jaybell
75e6297f09 feat(common): add <link> preload tag on server for priority img (#47343)
This commit adds a logic that generates preload tags for priority images, when rendering happens on the server (e.g. Angular Universal).

PR Close #47343
2022-10-10 20:48:10 +00:00
Pawel Kozlowski
2c8579f1b4 refactor(common): decouple preconnect checks from image loaders (#47565)
Previously the built-in image loaders for the optimized image directive
were tightly coupled to the preconnect checks infrastructure. This was
creating a problem when developers were trying to provide a loader on
a component level (or, more generally, deeper in the DI hierarchy):
- PreconnectLinkChecker is the application-level service, provided in root;
- it makes sense to provide loaders in different parts of the DI hierarchy;

This refactoring removes the PreconnectLinkChecker configuration from
the loaders infrastructure and makes it application-wide config. The
PRECONNECT_CHECK_BLOCKLIST is also a simple provider (it was a
multi-provider previously) which should make the overall configuration
easier.

PR Close #47565
2022-09-29 16:39:35 -07:00
Kara Erickson
f81765b333 feat(common): warn if rendered size is much smaller than intrinsic (#47082)
This commit adds a console warning in development mode
if the ultimate rendered size of the image is much
smaller than the dimensions of the requested image.
In this case, the warning recommends adjusting the
size of the source image or using the `rawSrcset`
attribute to implement responsive sizing.

PR Close #47082
2022-08-16 17:36:54 +00:00
Andrew Kushnir
8106084679 refactor(common): throw an error if an absolute URL is passed to Image Loaders (#47082)
This commit updates the logic of Image Loaders to throw an error in case an absolute URL is provided an an input to the loader function. The loaders can construct URLs based on image paths relative to the bas URL configured for a loader.

PR Close #47082
2022-08-16 17:36:53 +00:00
Andrew Kushnir
586274fe65 feat(common): provide an ability to exclude origins from preconnect checks in NgOptimizedImage (#47082)
This commit adds an extra logic to add an ability to exclude origins from preconnect checks in NgOptimizedImage by configuring the `PRECONNECT_CHECK_BLOCKLIST` multi-provider.

PR Close #47082
2022-08-16 17:36:53 +00:00
Andrew Kushnir
7baf9a46cd feat(common): verify that priority images have preconnect links (#47082)
This commit updates the `NgOptimizedImage` directive to add a logic to detect whether an image, marked with the "priority" attribute has a corresponding `<link rel="preconnect">` tag in the `document.head` for better performance.

PR Close #47082
2022-08-16 17:36:53 +00:00
Kara Erickson
ae4405f0bf fix(common): throw if srcset is used with rawSrc (#47082)
Currently if you use a static `srcset` with the image directive,
lazy loading no longer works because the image would start to
load before the loading attribute could be set to "lazy". This
commit throws an error if you try to use `srcset` this way.

In a follow-up commit, a new attribute will be added to support
responsive images in a lazy-loading-friendly way.

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
d3c3426aa4 feat(common): detect LCP images in NgOptimizedImage and assert if priority is set (#47082)
This commit adds extra logic into the `NgOptimizedImage` experimental directive to detect an LCP image and assert whether the `priority` attribute is applied.

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
4a01b204d3 refactor(common): throw an error if width or height inputs are missing or invalid (#47082)
This commit updates the `NgOptimizeImage` directive to add asserts to make sure the `width` and `height` inputs are set and have correct values (numbers only).

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
2e0d09354f refactor(common): throw an error if NgOptimizeImage inputs change (#47082)
This commit updates the `NgOptimizeImage` directive to add asserts to make sure no inputs are changed after directive initialization.

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
86e77a5d55 feat(common): add Image directive skeleton (#45627) (#47082)
This commit adds Image directive skeleton as well as a set of basic tests.

PR Close #47082
2022-08-16 17:36:51 +00:00
Jessica Janiuk
606d94299a fix(core): Update ngfor error code to be negative (#46555)
This adds the fancy link to the error code documentation automatically

PR Close #46555
2022-06-28 12:59:07 -07:00
Jessica Janiuk
f86e0948f8 fix(core): Updates error to use RuntimeError code (#46526)
This updates the iterable differ error to use more up-to-date error
codes.

PR Close #46526
2022-06-28 00:29:54 -07:00
Ramesh Thiruchelvam
4307b82058 refactor(common): make the error messages tree shakable (#44663)
Make Long error messages tree-shakable in the production build with error codes.

fixes #40096

PR Close #44663
2022-01-18 10:31:44 -08:00
Andrew Kushnir
66e59bc11a refactor(core): make RuntimeError reusable across packages (#44398)
This commit updates the code around the `RuntimeError` class to make it more reusable between packages (currently it's only usable inside the `core` package). Specifically:
- the error formatting logic was updated to handle cases when there is no error message provided
- there is no special Set that contains a set of error codes for which we have guides on angular.io. Instead, this is now encoded into the error code itself (making such codes negative integers). Having a separate Set makes it non-tree-shakable, which we want to avoid.

This change should allow to employ the `RuntimeError` class in other packages to further standardize this subsystem and make the errors thrown by the framework consistent.

As a part of the refactoring, the `common` package code was also updated to follow the same logic as `core`, since the `RuntimeError` class was used there as well.

PR Close #44398
2022-01-06 23:43:18 +00:00