Skip to content
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

Deprecate the feature-exists function #2235

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## 1.78.0

* The `meta.feature-exists` function is now deprecated. This deprecation is
named `feature-exists`.

* Fix a crash when using `@at-root` without any queries or children in the
indented syntax.

Expand Down
6 changes: 5 additions & 1 deletion lib/src/deprecation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum Deprecation {
// DO NOT EDIT. This section was generated from the language repo.
// See tool/grind/generate_deprecations.dart for details.
//
// Checksum: 309e4f1f008f08379b824ab6094e13df2e18e187
// Checksum: dd5c6aa0f1431fa9fc88bb71a96f832adbc165f5

/// Deprecation for passing a string directly to meta.call().
callString('call-string',
Expand Down Expand Up @@ -95,6 +95,10 @@ enum Deprecation {
deprecatedIn: '1.77.7',
description: 'Declarations after or between nested rules.'),

/// Deprecation for meta.feature-exists
featureExists('feature-exists',
deprecatedIn: '1.78.0', description: 'meta.feature-exists'),

/// Deprecation for @import rules.
import.future('import', description: '@import rules.'),

Expand Down
6 changes: 6 additions & 0 deletions lib/src/functions/meta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'package:collection/collection.dart';

import '../ast/sass/statement/mixin_rule.dart';
import '../callable.dart';
import '../deprecation.dart';
import '../evaluation_context.dart';
import '../util/map.dart';
import '../value.dart';

Expand All @@ -26,6 +28,10 @@ final global = UnmodifiableListView([
// evaluator, because they need access to context that's only available at
// runtime.
_function("feature-exists", r"$feature", (arguments) {
warnForDeprecation(
"The feature-exists() function is deprecated.\n\n"
"More info: https://sass-lang.com/d/feature-exists",
Deprecation.featureExists);
var feature = arguments[0].assertString("feature");
return SassBoolean(_features.contains(feature.text));
}),
Expand Down