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

[Color 4] Update behavior to match updated spec #2251

Merged
merged 6 commits into from
Jul 18, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
is now interpreted as a percentage, instead of ignoring the unit. For example,
`color.change(red, $alpha: 50%)` now returns `rgb(255 0 0 / 0.5)`.

* **Potentially breaking compatibility fix**: Sass no longer rounds RGB channels
to the nearest integer. This means that, for example, `rgb(0 0 1) != rgb(0 0
0.6)`. This matches the latest version of the CSS spec and browser behavior.

* **Potentially breaking compatibility fix**: Passing large positive or negative
values to `color.adjust()` can now cause a color's channels to go outside that
color's gamut. In most cases this will currently be clipped by the browser and
Expand Down
8 changes: 4 additions & 4 deletions lib/src/ast/css/modifiable/node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract base class ModifiableCssNode extends CssNode {
ModifiableCssParentNode? get parent => _parent;
ModifiableCssParentNode? _parent;

/// The index of [this] in `parent.children`.
/// The index of `this` in `parent.children`.
///
/// This makes [remove] more efficient.
int? _indexInParent;
Expand All @@ -33,7 +33,7 @@ abstract base class ModifiableCssNode extends CssNode {

T accept<T>(ModifiableCssVisitor<T> visitor);

/// Removes [this] from [parent]'s child list.
/// Removes `this` from [parent]'s child list.
///
/// Throws a [StateError] if [parent] is `null`.
void remove() {
Expand Down Expand Up @@ -65,10 +65,10 @@ abstract base class ModifiableCssParentNode extends ModifiableCssNode
: _children = children,
children = UnmodifiableListView(children);

/// Returns whether [this] is equal to [other], ignoring their child nodes.
/// Returns whether `this` is equal to [other], ignoring their child nodes.
bool equalsIgnoringChildren(ModifiableCssNode other);

/// Returns a copy of [this] with an empty [children] list.
/// Returns a copy of `this` with an empty [children] list.
///
/// This is *not* a deep copy. If other parts of this node are modifiable,
/// they are shared between the new and old nodes.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ast/sass/at_root_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class AtRootQuery {
{Object? url, Logger? logger, InterpolationMap? interpolationMap}) =>
AtRootQueryParser(contents, url: url, logger: logger).parse();

/// Returns whether [this] excludes [node].
/// Returns whether `this` excludes [node].
///
/// @nodoc
@internal
Expand All @@ -76,6 +76,6 @@ final class AtRootQuery {
};
}

/// Returns whether [this] excludes an at-rule with the given [name].
/// Returns whether `this` excludes an at-rule with the given [name].
bool excludesName(String name) => (_all || names.contains(name)) != include;
}
6 changes: 3 additions & 3 deletions lib/src/ast/sass/expression/binary_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ enum BinaryOperator {
/// The modulo operator, `%`.
modulo('modulo', '%', 6);

/// The English name of [this].
/// The English name of `this`.
final String name;

/// The Sass syntax for [this].
/// The Sass syntax for `this`.
final String operator;

/// The precedence of [this].
/// The precedence of `this`.
///
/// An operator with higher precedence binds tighter.
final int precedence;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast/sass/expression/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class ListExpression implements Expression {
return buffer.toString();
}

/// Returns whether [expression], contained in [this], needs parentheses when
/// Returns whether [expression], contained in `this`, needs parentheses when
/// printed as Sass source.
bool _elementNeedsParens(Expression expression) => switch (expression) {
ListExpression(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast/sass/expression/string.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class StringExpression implements Expression {
/// included.
final Interpolation text;

/// Whether [this] has quotes.
/// Whether `this` has quotes.
final bool hasQuotes;

FileSpan get span => text.span;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ast/sass/expression/unary_operation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ enum UnaryOperator {
/// The boolean negation operator, `not`.
not('not', 'not');

/// The English name of [this].
/// The English name of `this`.
final String name;

/// The Sass syntax for [this].
/// The Sass syntax for `this`.
final String operator;

const UnaryOperator(this.name, this.operator);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast/selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ abstract base class Selector implements AstNode {

Selector(this.span);

/// Prints a warning if [this] is a bogus selector.
/// Prints a warning if `this` is a bogus selector.
///
/// This may only be called from within a custom Sass function. This will
/// throw a [SassException] in Dart Sass 2.0.0.
Expand Down
4 changes: 2 additions & 2 deletions lib/src/ast/selector/list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ final class SelectorList extends Selector {
return contents.isEmpty ? null : SelectorList(contents, span);
}

/// Returns a new selector list that represents [this] nested within [parent].
/// Returns a new selector list that represents `this` nested within [parent].
///
/// By default, this replaces [ParentSelector]s in [this] with [parent]. If
/// By default, this replaces [ParentSelector]s in `this` with [parent]. If
/// [preserveParentSelectors] is true, this instead preserves those selectors
/// as parent selectors.
///
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast/selector/pseudo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ final class PseudoSelector extends SimpleSelector {
for (var simple in compound) {
if (simple case PseudoSelector(isElement: true)) {
// A given compound selector may only contain one pseudo element. If
// [compound] has a different one than [this], unification fails.
// [compound] has a different one than `this`, unification fails.
if (isElement) return null;

// Otherwise, this is a pseudo selector and should come before pseudo
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast/selector/simple.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abstract base class SimpleSelector extends Selector {
url: url, logger: logger, allowParent: allowParent)
.parseSimpleSelector();

/// Returns a new [SimpleSelector] based on [this], as though it had been
/// Returns a new [SimpleSelector] based on `this`, as though it had been
/// written with [suffix] at the end.
///
/// Assumes [suffix] is a valid identifier suffix. If this wouldn't produce a
Expand Down
4 changes: 2 additions & 2 deletions lib/src/async_environment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ final class AsyncEnvironment {
return Configuration.implicit(configuration);
}

/// Returns a module that represents the top-level members defined in [this],
/// Returns a module that represents the top-level members defined in `this`,
/// that contains [css] and [preModuleComments] as its CSS, which can be
/// extended using [extensionStore].
Module toModule(
Expand All @@ -802,7 +802,7 @@ final class AsyncEnvironment {
forwarded: _forwardedModules.andThen((modules) => MapKeySet(modules)));
}

/// Returns a module with the same members and upstream modules as [this], but
/// Returns a module with the same members and upstream modules as `this`, but
/// an empty stylesheet and extension store.
///
/// This is used when resolving imports, since they need to inject forwarded
Expand Down
6 changes: 3 additions & 3 deletions lib/src/environment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// DO NOT EDIT. This file was generated from async_environment.dart.
// See tool/grind/synchronize.dart for details.
//
// Checksum: f7172be68e0a19c4dc2d2ad04fc32a843a98a6bd
// Checksum: e1beeae58a4d5b97cd7d4f01c7d46b0586b508b9
//
// ignore_for_file: unused_import

Expand Down Expand Up @@ -796,7 +796,7 @@ final class Environment {
return Configuration.implicit(configuration);
}

/// Returns a module that represents the top-level members defined in [this],
/// Returns a module that represents the top-level members defined in `this`,
/// that contains [css] and [preModuleComments] as its CSS, which can be
/// extended using [extensionStore].
Module<Callable> toModule(
Expand All @@ -808,7 +808,7 @@ final class Environment {
forwarded: _forwardedModules.andThen((modules) => MapKeySet(modules)));
}

/// Returns a module with the same members and upstream modules as [this], but
/// Returns a module with the same members and upstream modules as `this`, but
/// an empty stylesheet and extension store.
///
/// This is used when resolving imports, since they need to inject forwarded
Expand Down
10 changes: 5 additions & 5 deletions lib/src/extend/extension_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ class ExtensionStore {
}
}

/// Extends [this] with all the extensions in [extensions].
/// Extends `this` with all the extensions in [extensions].
///
/// These extensions will extend all selectors already in [this], but they
/// These extensions will extend all selectors already in `this`, but they
/// will *not* extend other extensions from [extensionStores].
void addExtensions(Iterable<ExtensionStore> extensionStores) {
// Extensions already in [this] whose extenders are extended by
// Extensions already in `this` whose extenders are extended by
// [extensions], and thus which need to be updated.
List<Extension>? extensionsToExtend;

Expand Down Expand Up @@ -973,8 +973,8 @@ class ExtensionStore {
return specificity;
}

/// Returns a copy of [this] that extends new selectors, as well as a map
/// (with reference equality) from the selectors extended by [this] to the
/// Returns a copy of `this` that extends new selectors, as well as a map
/// (with reference equality) from the selectors extended by `this` to the
/// selectors extended by the new [ExtensionStore].
(ExtensionStore, Map<SelectorList, Box<SelectorList>>) clone() {
var newSelectors = <SimpleSelector, Set<ModifiableBox<SelectorList>>>{};
Expand Down
Loading
Loading