Skip to content

Commit 0d228c5

Browse files
committed
Drop support for @elseif
1 parent 03de3a8 commit 0d228c5

File tree

6 files changed

+18
-163
lines changed

6 files changed

+18
-163
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
## 2.0.0
22

3+
* **Breaking change:** `@elseif` is no longer treated as equivalent to `@else
4+
if`, and is now treated like any other unknown plain CSS at-rule.
5+
36
* **Breaking change:** The `@-moz-document` rule no longer has any special
47
parsing associated with it. It is now parsed like any other unknown plain CSS
58
at-rule, where Sass features are only allowed within `#{}` interpolation.
6-
9+
710
### Bogus Combinators
811

912
* **Breaking change:** Selectors with more than one combinator in a row, such as

lib/src/deprecation.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ enum Deprecation {
1515
// DO NOT EDIT. This section was generated from the language repo.
1616
// See tool/grind/generate_deprecations.dart for details.
1717
//
18-
// Checksum: cd61dac9558368fdb6f4221bb23d917003b61610
18+
// Checksum: e386251fa5eea522619d91ac98daf84dd474c29d
1919

2020
/// Deprecation for passing a string directly to meta.call().
2121
callString('call-string',
2222
deprecatedIn: '0.0.0',
2323
description: 'Passing a string directly to meta.call().'),
2424

2525
/// Deprecation for @elseif.
26-
elseif('elseif', deprecatedIn: '1.3.2', description: '@elseif.'),
26+
elseif('elseif',
27+
deprecatedIn: '1.3.2', obsoleteIn: '2.0.0', description: '@elseif.'),
2728

2829
/// Deprecation for @-moz-document.
2930
mozDocument('moz-document',

lib/src/parse/scss.dart

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import 'package:charcode/charcode.dart';
66

77
import '../ast/sass.dart';
8-
import '../deprecation.dart';
98
import '../interpolation_buffer.dart';
109
import '../util/character.dart';
1110
import 'stylesheet.dart';
@@ -39,25 +38,12 @@ class ScssParser extends StylesheetParser {
3938
bool scanElse(int ifIndentation) {
4039
var start = scanner.state;
4140
_whitespace();
42-
var beforeAt = scanner.state;
43-
if (scanner.scanChar($at)) {
44-
if (scanIdentifier('else', caseSensitive: true)) return true;
45-
if (scanIdentifier('elseif', caseSensitive: true)) {
46-
warnings.add((
47-
deprecation: Deprecation.elseif,
48-
message:
49-
'@elseif is deprecated and will not be supported in future Sass '
50-
'versions.\n'
51-
'\n'
52-
'Recommendation: @else if',
53-
span: scanner.spanFrom(beforeAt),
54-
));
55-
scanner.position -= 2;
56-
return true;
57-
}
41+
if (scanner.scanChar($at) && scanIdentifier('else', caseSensitive: true)) {
42+
return true;
43+
} else {
44+
scanner.state = start;
45+
return false;
5846
}
59-
scanner.state = start;
60-
return false;
6147
}
6248

6349
List<Statement> children(Statement child()) {

test/cli/shared/deprecations.dart

Lines changed: 5 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -113,45 +113,7 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
113113

114114
group("silences", () {
115115
group("a parse-time deprecation", () {
116-
setUp(
117-
() => d.file("test.scss", "@if true {} @elseif false {}").create(),
118-
);
119-
120-
test("in immediate mode", () async {
121-
var sass = await runSass([
122-
"--silence-deprecation=elseif",
123-
"test.scss",
124-
]);
125-
expect(sass.stderr, emitsDone);
126-
await sass.shouldExit(0);
127-
});
128-
129-
test("in watch mode", () async {
130-
var sass = await runSass([
131-
"--watch",
132-
"--poll",
133-
"--silence-deprecation=elseif",
134-
"test.scss:out.css",
135-
]);
136-
expect(sass.stderr, emitsDone);
137-
138-
await expectLater(
139-
sass.stdout,
140-
emitsThrough(endsWith('Compiled test.scss to out.css.')),
141-
);
142-
await sass.kill();
143-
});
144-
145-
test("in repl mode", () async {
146-
var sass = await runSass([
147-
"--interactive",
148-
"--silence-deprecation=strict-unary",
149-
]);
150-
expect(sass.stderr, emitsDone);
151-
sass.stdin.writeln("4 -(5)");
152-
await expectLater(sass.stdout, emitsInOrder([">> 4 -(5)", "-1"]));
153-
await sass.kill();
154-
});
116+
// TODO: Test this again once new deprecations are added post-2.0.0.
155117
});
156118

157119
group("an evaluation-time deprecation", () {
@@ -227,43 +189,15 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
227189
}, skip: true);
228190

229191
test("for a silent deprecation", () async {
230-
var sass = await runSass([
231-
"--fatal-deprecation=elseif",
232-
"--silence-deprecation=elseif",
233-
"test.scss",
234-
]);
235-
expect(sass.stderr, emits(contains("Ignoring setting to silence")));
236-
await sass.shouldExit(0);
192+
// TODO: Test this again once new deprecations are added post-2.0.0.
237193
});
238194

239195
test("in watch mode", () async {
240-
var sass = await runSass([
241-
"--watch",
242-
"--poll",
243-
"--fatal-deprecation=elseif",
244-
"--silence-deprecation=elseif",
245-
"test.scss:out.css",
246-
]);
247-
expect(sass.stderr, emits(contains("Ignoring setting to silence")));
248-
249-
await expectLater(
250-
sass.stdout,
251-
emitsThrough(endsWith('Compiled test.scss to out.css.')),
252-
);
253-
await sass.kill();
196+
// TODO: Test this again once new deprecations are added post-2.0.0.
254197
});
255198

256199
test("in repl mode", () async {
257-
var sass = await runSass([
258-
"--interactive",
259-
"--fatal-deprecation=elseif",
260-
"--silence-deprecation=elseif",
261-
]);
262-
await expectLater(
263-
sass.stderr,
264-
emits(contains("Ignoring setting to silence")),
265-
);
266-
await sass.kill();
200+
// TODO: Test this again once new deprecations are added post-2.0.0.
267201
});
268202
});
269203

@@ -311,54 +245,7 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
311245
});
312246

313247
group("a parse-time deprecation", () {
314-
setUp(
315-
() => d.file("test.scss", "@if true {} @elseif false {}").create(),
316-
);
317-
318-
test("in immediate mode", () async {
319-
var sass = await runSass(["--fatal-deprecation=elseif", "test.scss"]);
320-
expect(sass.stderr, emits(startsWith("Error: ")));
321-
await sass.shouldExit(65);
322-
});
323-
324-
test("in watch mode", () async {
325-
var sass = await runSass([
326-
"--watch",
327-
"--poll",
328-
"--fatal-deprecation=elseif",
329-
"test.scss:out.css",
330-
]);
331-
await expectLater(sass.stderr, emits(startsWith("Error: ")));
332-
await expectLater(
333-
sass.stdout,
334-
emitsInOrder([
335-
"Sass is watching for changes. Press Ctrl-C to stop.",
336-
"",
337-
]),
338-
);
339-
await sass.kill();
340-
});
341-
342-
test("in repl mode", () async {
343-
var sass = await runSass([
344-
"--interactive",
345-
"--fatal-deprecation=strict-unary",
346-
]);
347-
sass.stdin.writeln("4 -(5)");
348-
await expectLater(
349-
sass.stdout,
350-
emitsInOrder([
351-
">> 4 -(5)",
352-
emitsThrough(startsWith("Error: ")),
353-
emitsThrough(contains("Remove this setting")),
354-
]),
355-
);
356-
357-
// Verify that there's no output written for the previous line.
358-
sass.stdin.writeln("1");
359-
await expectLater(sass.stdout, emitsInOrder([">> 1", "1"]));
360-
await sass.kill();
361-
});
248+
// TODO: Test this again once new deprecations are added post-2.0.0.
362249
});
363250

364251
group("an evaluation-time deprecation", () {

test/deprecations_test.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ void main() {
1515
_expectDeprecation("a { b: call(random)}", Deprecation.callString);
1616
});
1717

18-
// Deprecated in 1.3.2
19-
test("elseIf is violated by using @elseif instead of @else if", () {
20-
_expectDeprecation("@if false {} @elseif false {}", Deprecation.elseif);
21-
});
22-
2318
// Deprecated in 1.17.2
2419
test("newGlobal is violated by declaring a new variable with !global", () {
2520
_expectDeprecation(r"a {$foo: bar !global;}", Deprecation.newGlobal);

test/embedded/protocol_test.dart

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -440,24 +440,7 @@ void main() {
440440
});
441441

442442
test("for a parse-time deprecation warning", () async {
443-
process.send(compileString("@if true {} @elseif true {}"));
444-
445-
var logEvent = await getLogEvent(process);
446-
expect(logEvent.type, equals(LogEventType.DEPRECATION_WARNING));
447-
expect(
448-
logEvent.message,
449-
equals(
450-
'@elseif is deprecated and will not be supported in future Sass '
451-
'versions.\n'
452-
'\n'
453-
'Recommendation: @else if',
454-
),
455-
);
456-
expect(logEvent.span.text, equals("@elseif"));
457-
expect(logEvent.span.start, equals(location(12, 0, 12)));
458-
expect(logEvent.span.end, equals(location(19, 0, 19)));
459-
expect(logEvent.span.context, equals("@if true {} @elseif true {}"));
460-
expect(logEvent.stackTrace, "- 1:13 root stylesheet\n");
443+
// TODO: Test this again once new deprecations are added post-2.0.0.
461444
await process.kill();
462445
});
463446

0 commit comments

Comments
 (0)