mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-08 15:51:16 +08:00
fix(config): allow LogLevel to work with isolatedModules and update all warns and errors to respect logLevel (#30350)
Issue number: internal --------- ## What is the current behavior? - `LogLevel` throws error `Error: Cannot access ambient const enums when 'isolatedModules' is enabled` - Several existing console warns and errors are not calling the function that respects the `logLevel` config ## What is the new behavior? - Remove `const` from the `enum` to work with `isolatedModules` - Update `console.warn`s to `printIonWarning` - Update `console.error`s to `printIonError` ## Does this introduce a breaking change? - [ ] Yes - [x] No ## Other information Dev build: `8.5.5-dev.11744729748.174bf7e0` --------- Co-authored-by: Brandy Smith <6577830+brandyscarney@users.noreply.github.com>
This commit is contained in:
@ -83,7 +83,7 @@ export function getAnimationPosition(
|
||||
function warnIfAnchorIsHidden(positionAnchor: HTMLElement, toast: HTMLElement) {
|
||||
if (positionAnchor.offsetParent === null) {
|
||||
printIonWarning(
|
||||
'The positionAnchor element for ion-toast was found in the DOM, but appears to be hidden. This may lead to unexpected positioning of the toast.',
|
||||
'[ion-toast] - The positionAnchor element for ion-toast was found in the DOM, but appears to be hidden. This may lead to unexpected positioning of the toast.',
|
||||
toast
|
||||
);
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ import { ENABLE_HTML_CONTENT_DEFAULT } from '@utils/config';
|
||||
import type { Gesture } from '@utils/gesture';
|
||||
import { raf } from '@utils/helpers';
|
||||
import { createLockController } from '@utils/lock-controller';
|
||||
import { printIonWarning } from '@utils/logging';
|
||||
import { printIonError, printIonWarning } from '@utils/logging';
|
||||
import {
|
||||
GESTURE,
|
||||
createDelegateController,
|
||||
@ -498,7 +498,7 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
}
|
||||
|
||||
if (position === 'middle' && positionAnchor !== undefined) {
|
||||
printIonWarning('The positionAnchor property is ignored when using position="middle".', this.el);
|
||||
printIonWarning('[ion-toast] - The positionAnchor property is ignored when using position="middle".', this.el);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -511,7 +511,10 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
*/
|
||||
const foundEl = document.getElementById(positionAnchor);
|
||||
if (foundEl === null) {
|
||||
printIonWarning(`An anchor element with an ID of "${positionAnchor}" was not found in the DOM.`, el);
|
||||
printIonWarning(
|
||||
`[ion-toast] - An anchor element with an ID of "${positionAnchor}" was not found in the DOM.`,
|
||||
el
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -522,7 +525,7 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
return positionAnchor;
|
||||
}
|
||||
|
||||
printIonWarning('Invalid positionAnchor value:', positionAnchor, el);
|
||||
printIonWarning('[ion-toast] - Invalid positionAnchor value:', positionAnchor, el);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -549,7 +552,7 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
printIonError('[ion-toast] - Exception in callButtonHandler:', e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -705,7 +708,7 @@ export class Toast implements ComponentInterface, OverlayInterface {
|
||||
*/
|
||||
if (layout === 'stacked' && startButtons.length > 0 && endButtons.length > 0) {
|
||||
printIonWarning(
|
||||
'This toast is using start and end buttons with the stacked toast layout. We recommend following the best practice of using either start or end buttons with the stacked toast layout.',
|
||||
'[ion-toast] - This toast is using start and end buttons with the stacked toast layout. We recommend following the best practice of using either start or end buttons with the stacked toast layout.',
|
||||
el
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user