Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor: remove expensive no-op call to _get-token-slots #31138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions src/material/core/tokens/_m3-tokens.scss
Original file line number Diff line number Diff line change
@@ -1,35 +1,7 @@
@use '../m2' as m2-theming;
@use '../style/sass-utils';
@use './m2-tokens';
@use './m3';
@use 'sass:map';

$_cached-token-slots: null;

/// Determines the token slots for all components.
@function _get-token-slots() {
// Cache the slots since they're constant and calculating
// them appears to be expensive (see #29009).
@if ($_cached-token-slots) {
@return $_cached-token-slots;
}

// TODO(mmalerba): Refactor this to not depend on the legacy theme when moving out of
// material-experimental. This is a hack for now because there is no good way to get the token
// slots in material-experimental without exposing them all from material.
$fake-theme: m2-theming.define-light-theme((
color: (
primary: m2-theming.define-palette(m2-theming.$red-palette),
accent: m2-theming.define-palette(m2-theming.$red-palette),
warn: m2-theming.define-palette(m2-theming.$red-palette),
),
typography: m2-theming.define-typography-config(),
density: 0
));
$_cached-token-slots: m2-tokens.m2-tokens-from-theme($fake-theme) !global;
@return $_cached-token-slots;
}

/// Generates a set of namespaced tokens for all components.
/// @param {Map} $systems The MDC system tokens
/// @param {Boolean} $include-non-systemized Whether to include non-systemized tokens
Expand All @@ -46,8 +18,6 @@ $_cached-token-slots: null;
), $systems);
$exclude-hardcoded: not $include-non-systemized;

$token-slots: _get-token-slots();

// TODO(mmalerba): Fill in remaining tokens.
$result: sass-utils.deep-merge-all(
// Add the system color & typography tokens (so we can give users access via an API).
Expand Down
Loading