Skip to content

Commit

Permalink
Deprecate the feature-exists function
Browse files Browse the repository at this point in the history
  • Loading branch information
stof committed Aug 17, 2024
1 parent 9d45fad commit 28b639c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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`.

### JS API

* Fix a bug where accessing `SourceSpan.url` would crash when a relative URL was
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

0 comments on commit 28b639c

Please sign in to comment.