Commit Graph

1267 Commits

Author SHA1 Message Date
Jennifer Thakar
f5e3a5a669
Add support for nested maps to has-key (#1075) 2020-09-16 14:41:23 -07:00
Jennifer Thakar
6b66241e95
Add support for nested maps to map-get (#1076) 2020-09-16 13:23:52 -07:00
Natalie Weizenbaum
028b2f6a01 Add a map.deep-merge() function (#1077) (#1080)
This also adds a Value.tryMap() function, which was useful for
implementing this and may be more generally useful to users as well.

See sass/sass#2836
See sass/sass-spec#1560
2020-09-15 16:25:49 -07:00
Natalie Weizenbaum
015a76cf0b Revert "Add a map.deep-merge() function (#1077) (#1080)"
This reverts commit 315e86b442.

Once again, this was supposed to go on feature.nested-maps.
2020-09-15 16:24:53 -07:00
Natalie Weizenbaum
315e86b442
Add a map.deep-merge() function (#1077) (#1080)
This also adds a Value.tryMap() function, which was useful for
implementing this and may be more generally useful to users as well.

See sass/sass#2836
See sass/sass-spec#1560
2020-09-15 16:23:01 -07:00
Natalie Weizenbaum
9503b57ac5 Revert "Add a map.deep-merge() function (#1077)"
This reverts commit bc7216a441.

This was intended to land on a feature branch, not on master.
2020-09-15 15:17:55 -07:00
Natalie Weizenbaum
bc7216a441
Add a map.deep-merge() function (#1077)
This also adds a Value.tryMap() function, which was useful for
implementing this and may be more generally useful to users as well.

See sass/sass#2836
See sass/sass-spec#1560
2020-09-15 13:03:38 -07:00
Natalie Weizenbaum
a06295426d
Throw a proper error when the same built-in module is @used twice (#1070)
Closes #1047
2020-09-04 12:26:29 -07:00
Natalie Weizenbaum
1dff9a7ce4
Don't crash when writing Infinity in JS mode (#1069)
Closes #1031
2020-09-04 12:25:42 -07:00
Natalie Weizenbaum
4c0bc7f4f5
Throw an error if the first error to selector.nest() contains & (#1068)
Closes #966
2020-09-03 16:00:14 -07:00
Anthon Pang
330d93c2c1
Rename listIsSuperslector (#1062) 2020-08-24 09:46:26 -07:00
Natalie Weizenbaum
9f640625e9
Improve the error messages for syntax errors (#1055)
* Produce a useful error for "@else i<EOF>"

* Produce a useful error for out-of-range hex escapes

Closes #1029, #1049, #1030
2020-08-10 13:55:13 -07:00
Jennifer Thakar
9375ada8e6
Fix a selector parsing bug in indented syntax (#1005)
Fixes #1002.

In the indented syntax, a selector list may continue onto another line
if the previous line ends with a comma. Previously, if there was a
comment after the comma, it wouldn't be recognized and the selector
would be broken in two (with the first selector having no properties).

This fixes the parser to ignore comments when looking for the comma at
the end of a line.

Also disables the formatting check to work around dart-lang/dart_style#940.
2020-08-06 15:43:16 -07:00
Jennifer Thakar
6565b45a6c
Fix a null pointer bug (#1041)
Fixes #1038.
2020-07-06 15:35:09 -07:00
Jennifer Thakar
7933e9e602
Replace use of deprecated mapMap with map literals (#1034) 2020-06-22 13:35:28 -07:00
Jennifer Thakar
7d6dae02a4
Always use absolute URLs in stdout source maps (#1021)
Fixes #1020.
2020-06-04 17:03:06 -07:00
Jennifer Thakar
fba0ea37a1
Properly handle escaped @else (#1014)
Fixes #1011.

This also fixes a bug where `@else` was parsed case-insensitively
(unlike all other Sass at-rules, which must be lowercase).
2020-05-28 11:48:24 -07:00
Jennifer Thakar
d155f3518e
Fix lints (#1010) 2020-05-21 13:48:01 -07:00
Natalie Weizenbaum
93dcf994d5
Update outdated docs for ImportCache.importCanonical(). (#982) 2020-05-13 12:47:52 -07:00
awjin
21a1c58b20 Don't read file if Node importer returns file and contents.
Instead, use `contents` with `file` as the canonical url.

Closes https://github.com/sass/dart-sass/issues/975.
2020-04-24 17:38:30 -07:00
Jennifer Thakar
7160b6426d
Add missing constants to JS API (#990)
Fixes #977.
2020-04-24 16:11:46 -07:00
Sam Rawlins
da6b2c5d01
Remove two unused constructors named '_none' (#979) 2020-04-23 12:24:59 -07:00
Natalie Weizenbaum
83ec64a1f2
Work around dart-lang/sdk#41259 (#984) 2020-04-21 16:03:58 -07:00
Natalie Weizenbaum
bf35513a4c
Avoid adding duplicate modules when importing forwarded stylesheets (#973)
Avoid adding duplicate modules when importing forwarded stylesheets

In Google stylesheets that imported import-only stylesheets with many
forwards many of times, we were seeing Environment._globalModules grow
large enough that variable accesses were a problem. This addresses
that in several ways:

* Forwarded modules are now ignored if the module is already being
  forwarded.

* Module equality is more intelligent, so that shadowed and forwarded
  modules can be effectively de-duplicated.

* If a module would be fully shadowed by a later import *and* that
  module has no CSS, we no longer add an empty ShadowedModule to the
  module list.
2020-03-24 15:31:06 -07:00
georgpukk
4d78316cb7
Fix a check that prevents compiling .css files to themselves (#968)
Co-Authored-By: Natalie Weizenbaum <nweiz@google.com>
2020-03-11 14:48:00 -07:00
Natalie Weizenbaum
cb8a048e58
Refactor Extender._extendOrReplace() (#965)
This combines all targets into a single extender invocation, which is
more efficient and allows it to more aggressively do redundant
selector elimination.
2020-02-28 15:48:36 -08:00
Natalie Weizenbaum
116165f76e Don't do a bunch of useless initial recanonicalization 2020-02-24 20:18:03 -08:00
Natalie Weizenbaum
a333059e71 Keep recompiling downstream dependencies after an error in --watch
Prior to this, the watcher handled all the logic around recompiling
stylesheets if an upstream file was deleted or added in a way that
could affect their import resolution. This left a gap where the
stylesheet graph wouldn't be aware that a newly-added file had become
upstream dependency of an existing downstream file, leading to
recompilation failures.

This commit fixes that by moving all that logic into the stylesheet
graph. The graph now has full and sole responsibility for providing a
consistent view of which stylesheets depend on one another even as the
shape of the graph changes, and the watcher is just a client of that
logic.

Closes #550
2020-02-24 20:18:03 -08:00
Natalie Weizenbaum
6d388248b6
Eagerly initialize Environment._globalModules (#952)
We had been lazily initializing this to be more efficient when no
global modules were used, but this meant that the object wasn't shared
with closures created for mixins and functions that were created when
it was still `null`, so later imported forwards weren't visible to
those members.
2020-02-13 15:23:53 -08:00
Natalie Weizenbaum
0a2142dc86
Don't include leading underscores in implicit namespaces (#955)
Closes #934
See sass/sass#2800
2020-02-12 12:52:53 -08:00
Natalie Weizenbaum
3e47570847
Properly check for double-forwarded functions and mixins (#951)
See #946
See sass/sass#2820
2020-02-10 16:30:00 -08:00
Natalie Weizenbaum
718cfdd6e3
Fix a bug where the wrong module was used for identity comparisons (#949) 2020-02-07 17:03:05 -08:00
Natalie Weizenbaum
67c4e1bdea
Don't throw conflict errors for identical members (#947)
See sass/sass#2820
Closes #946
2020-02-07 15:17:05 -08:00
Natalie Weizenbaum
fa1ddd28ad Add a separate Environment method to create dummy import modules
This avoids triggering `assert(!atRoot)` for nested environments,
while still having that precaution for normal `toModule()` calls.
2020-02-07 01:00:41 -08:00
Natalie Weizenbaum
77a58b34b6 Never return a null expression node when source maps are enabled 2020-02-07 01:00:41 -08:00
Natalie Weizenbaum
a95c5b8ccb Do variable index adjustments when accessing variables, not nodes
Doing this for variable *nodes* was breaking in extremely specific
circumstances:

* A null node is passed into setVariable() and, if source maps are
  enabled, recorded in _variableNodes.

* Later on, getVariableNode() is called for that variable. Because
  that variable's node is null, it calls
  _getVariableNodeFromGlobalModule() even though the variable is
  actually defined.

* _getVariableNodeFromGlobalModule() sets _lastVariableIndex to 0 on
  the assumption that the variable is undefined, which turns out to be
  incorrect in this specific case.

The next commit will fix the issue where a null node can be passed
into setVariable() when source maps are enabled, but it makes more
sense to assign the variable index to 0 in the variable access anyway,
since it happens first and isn't skipped when source maps are
disabled.
2020-02-07 00:51:46 -08:00
Natalie Weizenbaum
5709d90aaa Rename Environment.global to Environment.forImport
The previous name was misleading, since the environment could exist in
a nested context and thus contain local members.
2020-02-06 01:54:55 -08:00
Natalie Weizenbaum
6234489eaa
Explicitly set the JS class names for SassNull and SassBoolean (#941)
For whatever reason the default name seems to have changed.
2020-01-24 15:51:50 -08:00
Natalie Weizenbaum
5450c1c07b
Use cli_pkg to build and release executables (#924) 2020-01-24 13:05:04 -08:00
Natalie Weizenbaum
eeeac1d689
Give JavaScript value objects useful constructor.name values (#936)
Closes #810
2020-01-17 14:46:10 -08:00
awjin
4c0c6b48e4 Merge branch 'master' into math-functions 2020-01-16 14:55:40 -08:00
Natalie Weizenbaum
e4db19be3f Resynchronize 2020-01-15 16:21:07 -08:00
Natalie Weizenbaum
aa18e65f57 Code review 2020-01-15 15:55:55 -08:00
Awjin Ahn
75cab86448 Add trigonometric math functions. (#921)
See https://github.com/sass/sass-spec/pull/1504
2020-01-15 14:44:13 -08:00
Awjin Ahn
3cbaec11b2 Add exponential math functions. (#909) 2020-01-15 14:44:13 -08:00
awjin
d487d761bd Revert "Revert "Add built-in variables e and pi. (#907)""
This reverts commit 3c64addbf3.
2020-01-15 14:44:13 -08:00
awjin
5f72acb14d Revert "Revert "Adds built-in clamp() and hypot() (#906)""
This reverts commit 76280409bd.
2020-01-15 14:44:13 -08:00
Natalie Weizenbaum
d67f341a17 Indicate the original configuration location for multi-config errors 2020-01-11 00:12:38 -08:00
Natalie Weizenbaum
c2baede4db Throw multi-span exceptions for argument errors 2020-01-10 23:24:23 -08:00
Natalie Weizenbaum
0c1370ce25 Allow errors to refer to multiple source spans at once
This makes error messages for issues like configuring a module after
it's loaded much clearer.
2020-01-10 22:31:48 -08:00
Natalie Weizenbaum
ca63b1ba7d
Don't try to resolve relative Node importer URLs for source maps (#923)
* Don't try to resolve relative Node importer URLs for source maps

Closes #922

* Reformat
2020-01-09 13:14:44 -08:00
Lasse R.H. Nielsen
31c09606b9 Avoid depending on iterator.current != null. (#877)
With the NNBD change to Dart, it's no longer safe to rely on an iterator returning `null` when it has hit the end (or before calling `moveNext` the first time). For non-nullable element types, it will have to throw instead.

This PR rewrites code that currently rely on a `null` value to recognize the end of an iterator.
2020-01-07 13:58:48 -08:00
Jennifer Thakar
bfdf4b35a4
Fix import-only files for Node importers (#919) 2020-01-03 15:41:12 -08:00
Jennifer Thakar
79d9a73474
Cache separate canonical URLs for @use and @import (#908)
Fixes #899.

The cache for canonical URLs is now keyed on *both* the rule URL and
whether that URL was canonicalized for an `@import` rule.
2020-01-02 15:25:02 -08:00
Natalie Weizenbaum
92a28feb25
Replace whitelist/blacklist with safelist/blocklist (#917)
Inspired by https://twitter.com/amlyhamm/status/1202684742069604353.
2020-01-02 14:53:39 -08:00
Jennifer Thakar
76280409bd Revert "Adds built-in clamp() and hypot() (#906)"
This reverts commit 24f84e2c88.
2020-01-02 13:45:51 -08:00
Jennifer Thakar
3c64addbf3 Revert "Add built-in variables e and pi. (#907)"
This reverts commit 2cb69e70ab.
2020-01-02 13:45:49 -08:00
Awjin Ahn
2cb69e70ab
Add built-in variables e and pi. (#907) 2019-12-26 16:31:33 -08:00
Awjin Ahn
24f84e2c88
Adds built-in clamp() and hypot() (#906) 2019-12-26 12:40:08 -08:00
Natalie Weizenbaum
46be33e030 Merge branch 'master' of github.com:sass/dart-sass into forward-with 2019-12-19 16:10:51 -08:00
Natalie Weizenbaum
64cc529421 Reformat 2019-12-18 17:00:19 -08:00
Natalie Weizenbaum
ec3d0ddc19 Fix new pedantic lints 2019-12-18 15:46:36 -08:00
Natalie Weizenbaum
e35b51135b Code review 2019-12-17 15:26:43 -08:00
Natalie Weizenbaum
de3f3208e9 Support @forward ... with
See sass/sass#2744
Closes #846
2019-11-27 16:03:43 -08:00
Natalie Weizenbaum
af648bfa7c Drop Configuration.clone()
There was no reason not to use the original configuration.
2019-11-27 13:42:43 -08:00
Jennifer Thakar
8270dc1664
Support configuring modules through imports (#885)
Fixes #882

See sass/sass-spec#1497
2019-11-26 09:46:51 -08:00
Natalie Weizenbaum
15be59be31
Make SassFormatException implement SourceSpanFormatException (#891) 2019-11-25 18:54:45 -08:00
Natalie Weizenbaum
9635a523b7
Merge pull request #890 from sass/import-forward-twice
Fix some @import edge cases
2019-11-21 11:42:45 -08:00
Natalie Weizenbaum
731bd441ca Don't produce name conflict errors due to imports
Closes #888
2019-11-20 16:25:48 -08:00
Natalie Weizenbaum
3ec2f3faaa
Fix a documentation typo (#889) 2019-11-20 16:25:37 -08:00
Natalie Weizenbaum
aa76c8ab3b Always create scopes for nested imports 2019-11-20 16:21:03 -08:00
Natalie Weizenbaum
0d782fbccf
Fix inline comments in the indented syntax (#881)
Closes #880
2019-11-15 15:45:11 -08:00
Awjin Ahn
07b5c84b7d
Fix arity in overloaded function argument error (#883)
When overloaded functions receive an incorrect number of positional
arguments, determine which overload has the most similar number of
arguments, and then correctly display that number in the error.

Closes #520
sass/sass-spec#1496
2019-11-15 14:26:11 -08:00
Awjin Ahn
3d1dab3563 Print call-site for @errors in mixins and functions (#878)
For any @errors encountered in mixins or functions, use the call-site
(instead of the @error rule) as the span printed in the error message.

Closes #474
See sass/sass-spec#1494
2019-11-13 17:56:35 -08:00
Nate Bosch
7b0faec321 Migrate to stream_transform extension methods
The non-extension implementation will be removed in the next version.

Bump the min SDK to 2.6.0 to reflect the fact that extension methods are
used.
2019-11-06 14:47:24 -08:00
Natalie Weizenbaum
20978e0320 Fix new strict inference hints from Dart 2.6 2019-11-06 14:47:24 -08:00
Natalie Weizenbaum
44059573bb
Watch files through @forward rules (#871)
Closes #870
2019-11-04 13:32:27 -08:00
Natalie Weizenbaum
be4ca60045 Propagate selector source specificity between modules
Closes #866
2019-10-30 15:11:25 -07:00
Natalie Weizenbaum
df5f3af4e9 Remove some unused specificity calculations 2019-10-30 14:23:55 -07:00
Natalie Weizenbaum
3392db0074
Don't compile .css files in directories to themselves (#862)
This also adds support for compiling .css files in directories *at
all*, which had previously only worked in --watch mode.

Closes #853
2019-10-29 23:48:21 +00:00
Natalie Weizenbaum
1b17ab76cf
Reset the forwarded config to empty for @use and meta.load-module() (#855)
In #827 I made configuration never be null, but this turns out to be
overkill: we still need a way for _loadModule() and _execute() to
distinguish between "use the existing configuration" (for @forward)
and "use no configuration" (for an unconfigured @use or
meta.load-module()). We now use null as a sentinel value there, while
still ensuring that _configuration is non-nullable.

Closes #854
2019-10-22 01:35:11 +01:00
Natalie Weizenbaum
73de08b817
Only generate and update selectors, not rules, in Extender (#856)
We switched to *updating* selectors a while ago so that cloned rules
would continue to see updates in their selectors, but we were still
generating and tracking rules in the Extender. This caused skew
between what rules the extender knew about and what rules actually
existed in situations where rules were copied (such as when resolving
nested media queries).

There's no principled reason the extender needs to know about style
rules at all, so now it just tracks modifiable wrappers of selectors.
These are re-used even when style rules are cloned, so they're safe
from the skew problem.

Closes #843
2019-10-21 21:07:51 +01:00
Natalie Weizenbaum
6b8c168779
Improve error messages for color functions that aren't in sass:color (#844) 2019-10-14 17:56:13 -07:00
Natalie Weizenbaum
e68592f8f3
Allow saturate() in plain CSS files (#845)
Closes #840
2019-10-14 11:47:16 -07:00
XhmikosR
a95d61e886 Typo fixes (#842) 2019-10-10 15:33:36 -07:00
Jennifer Thakar
c663995f50
Only error for directly configured core modules (#839)
Fixes #838.
2019-10-10 14:33:54 -07:00
Natalie Weizenbaum
97203f1527 Merge branch 'feature.use' 2019-10-01 14:26:32 -07:00
Natalie Weizenbaum
fa3c657b56
Support multiple global uses in one file (#833)
Closes #832
2019-09-27 21:36:37 +01:00
Natalie Weizenbaum
7d3440698f
Remove adjust-hue() from sass:color (#828)
See sass/sass#2740
2019-09-27 21:27:26 +01:00
Natalie Weizenbaum
75305a1d21
Always use a non-null map for _EvaluateVisitor._configuration (#827)
We had been using null to represent an empty configuration, but that
caused problems when an empty map snuck its way in as well. Now we
always use maps, with a const empty map for the common case.

See sass/sass#2744
2019-09-27 21:19:24 +01:00
Natalie Weizenbaum
93a3a6f9f3 Merge branch 'master' into feature.use 2019-09-24 17:20:39 +01:00
Jennifer Thakar
553cf9a6d5 Fix bugs in RecursiveStatementVisitor (#824)
`AtRootRule.query` and `Declaration.value` can be null, so this should be checked before passing them on to `visitInterpolation` and `visitExpression`.
2019-09-23 07:33:28 -07:00
Natalie Weizenbaum
d901bcb00c
Properly handle some CSS identifier edge cases (#816)
See sass/sass#2738
Closes #815
2019-09-06 16:54:54 -07:00
Natalie Weizenbaum
aea990d4fc
Properly watch .css files for changes (#814)
Closes #806
2019-09-03 16:42:21 -07:00
Natalie Weizenbaum
4ccddf8b13
Dash-normalize user-defined functions (#813)
Closes #811
2019-09-03 16:00:07 -07:00
Natalie Weizenbaum
35880d171f
Check fs.existsSync() before running fs.statSync() (#812)
This produces non-negligible speed improvements for Node users with
lots of imports.
2019-09-03 13:26:57 -07:00
Natalie Weizenbaum
75c0452c1d Merge branch 'master' into feature.use 2019-09-02 13:58:21 -07:00
Natalie Weizenbaum
8dea51d410
Change variable syntax to namespace.$name (#803)
See sass/sass#2731
2019-08-29 15:31:03 -07:00
Natalie Weizenbaum
a89c67b563
Fix unquoted plain-CSS imports (#800)
Closes #799
2019-08-28 14:09:35 -07:00
Natalie Weizenbaum
fc8c987fc1
Fix a few @extend edge cases (#797) 2019-08-16 14:00:14 -07:00
Natalie Weizenbaum
0e5ed4a37d
Fix dash-insensitivity in get-function() (#795)
Closes #792
2019-08-14 12:20:47 -07:00
Natalie Weizenbaum
5349042994
Allow @use in the REPL (#784) 2019-07-30 00:51:54 +01:00
Natalie Weizenbaum
6775490251 Merge remote-tracking branch 'origin/master' into merge-master 2019-07-25 17:15:27 -07:00
Natalie Weizenbaum
d840b84b59 Clarify the error for the wrong number of positional arguments
Closes #776
2019-07-25 08:37:01 +01:00
Natalie Weizenbaum
d408a5994e Add a missing trailing "." to an error message
Closes #775
2019-07-25 08:37:01 +01:00
Natalie Weizenbaum
382af499e0 Avoid double "Error:" headers when reporting selector parse errors
Closes #774
2019-07-25 08:37:01 +01:00
Natalie Weizenbaum
44b542fcef Include argument names when reporting selector parse errors 2019-07-25 08:37:01 +01:00
Natalie Weizenbaum
8d5e3d9a67 Include argument names when reporting range errors
Closes #771
2019-07-25 08:37:00 +01:00
Natalie Weizenbaum
c971615fbf
Remove an unused Parser.scanWhitespace() method (#770)
Closes #767
2019-07-18 21:50:41 +01:00
Natalie Weizenbaum
e454647d27
Improve the error message for a global member conflict (#762) 2019-07-18 01:47:56 +01:00
Natalie Weizenbaum
0f8f7577a5 Don't create an intermediate stylesheet for @import if possible
We really only need this stylesheet when we're resolving imported
cross-module @extends, which doesn't come up very often.
2019-07-17 15:45:26 -07:00
Natalie Weizenbaum
c8770da29b Short-circuit combineCSS() if no upstream modules contain CSS 2019-07-17 15:45:00 -07:00
Natalie Weizenbaum
66c2c26a7e Use whereType() to avoid a cast 2019-07-17 15:45:00 -07:00
Natalie Weizenbaum
7b3a2adc12 Properly indicate the error location in the REPL
Previously, errors in variable assignment lines would be reported
incorrectly.
2019-07-17 15:45:00 -07:00
Natalie Weizenbaum
83cf390406 Delete a fixed TODO 2019-07-17 15:45:00 -07:00
Natalie Weizenbaum
c794abd858 Eagerly dash-normalize Sass identifiers
This avoids using maps and sets with custom equality, which are
moderately inefficient relative to built-in maps and sets on both Node
and the Dart VM. In order to make error messages continue to use the
original identifiers where possible, this updates some of them to rely
more heavily on their associated source spans for context.
2019-07-16 19:42:38 -07:00
Natalie Weizenbaum
437e04ea0b Merge remote-tracking branch 'origin/master' into feature.use 2019-07-16 18:49:15 -07:00
Natalie Weizenbaum
7f2055e775 Make colorsByName a normal map
There was no reason for this to be a normalized map, since color names
don't contain dashes or underscores.
2019-07-16 13:37:03 -07:00
Marcel Greter
d91e758889 Fix typo in silent comment error message (#761) 2019-07-16 00:44:32 +01:00
Natalie Weizenbaum
58e9e74b37 Use list comprehensions in *Evaluate._evaluateArguments
As well as being arguably more readable, the toList() method was
running a type check that was showing up as a minor bottleneck in JS
profiles.
2019-07-15 21:59:54 +01:00
Natalie Weizenbaum
a8e99e9152 Pass a dummy isValidKey callback to normalized map and set
The default implementation runs a type check, which was a performance
bottleneck when compiled to JS. There's no need for this type check in
practice, since we never pass a non-String value to the contains(),
containsKey(), or remove() methods (and if we do, it will throw a
TypeError in our tests).
2019-07-15 21:59:54 +01:00
Natalie Weizenbaum
0e47e03305
Fix at-rules in nested imports (#758)
Closes #755
2019-07-12 01:55:30 +01:00
Natalie Weizenbaum
2003f1c6ec Merge remote-tracking branch 'origin/master' into function-fixes 2019-07-03 16:56:54 -07:00
Natalie Weizenbaum
b7999e41ad
Fix a new lint (#752) 2019-07-03 16:56:33 -07:00
Natalie Weizenbaum
d3e288ccf2 Support map-remove() with a named $key argument
Closes #742
2019-07-03 15:31:56 -07:00
Natalie Weizenbaum
eff8c37457 Fix a deadlock in zip()
Closes #739
2019-07-03 15:31:56 -07:00
Natalie Weizenbaum
5ff434da6a Fix join() and append() $separator error messages
Closes #738
2019-07-03 15:31:56 -07:00
Natalie Weizenbaum
47e0cfc8c8 Empty maps have undecided separators
Closes #737
2019-07-03 15:31:56 -07:00
Natalie Weizenbaum
821b5e2521 Fix str-insert() with $index: -1
Closes #733
2019-07-02 17:25:46 -07:00
Natalie Weizenbaum
40df8e3bc1 Fix str-slice() with astral plane characters
Closes #732
2019-07-02 17:25:46 -07:00
Natalie Weizenbaum
2105a138c0 Clamp $alpha in adjust-color() with HSL args
Closes #708
2019-07-02 17:25:45 -07:00
Natalie Weizenbaum
7bfba04b79 Throw an error for plain-CSS invert() with $weight
Closes #705
2019-07-02 17:25:36 -07:00
Natalie Weizenbaum
d5adb4621e Fix invert() with $weight: 50%
Closes #704
2019-07-02 17:25:25 -07:00
Natalie Weizenbaum
9838caff6f Improve errors for alpha() with the wrong number of arguments
Closes #700
2019-07-02 17:25:14 -07:00
Natalie Weizenbaum
ed06a41afc Fix the argument name for a single-argument saturate() function
Closes #699
2019-07-02 16:10:28 -07:00
Natalie Weizenbaum
88774b3a07 Fix a Dart 2.4 analysis hint 2019-06-29 07:08:58 +01:00
Natalie Weizenbaum
72d932884f Merge remote-tracking branch 'origin/feature.use' into load-css 2019-06-29 05:54:39 +01:00
Natalie Weizenbaum
b8186fee05 Merge remote-tracking branch 'origin/master' into merge-master 2019-06-29 00:34:38 +01:00
Natalie Weizenbaum
532358d7fa
Merge pull request #727 from sass/static-require
Require dependencies in the preamble rather than through JS-interop
2019-06-28 14:32:18 -07:00
Natalie Weizenbaum
abf7d7f922
Fix a new analysis hint from Dart 2.4.0 (#743) 2019-06-28 14:32:04 -07:00
Natalie Weizenbaum
bfbe1efd3e Add a load-css() function 2019-06-27 14:12:38 -07:00
Natalie Weizenbaum
fe30fd61a3 Add the ability for built-in modules to expose mixins 2019-06-27 12:09:34 -07:00
Natalie Weizenbaum
6f89055ea6
Add support for "@use with" (#728) 2019-06-26 17:34:24 -07:00
Natalie Weizenbaum
18b06df84f Merge remote-tracking branch 'origin/master' into merge-master 2019-06-26 15:04:36 -07:00
Natalie Weizenbaum
174ef128a2 Merge remote-tracking branch 'origin/feature.use' into merge-use 2019-06-24 14:12:05 -07:00
Natalie Weizenbaum
19cfb63ab4
Address code review comments from #724 (#729) 2019-06-24 14:05:17 -07:00
Natalie Weizenbaum
494e208067 Require dependencies in the preamble rather than through JS-interop
Closes #726
2019-06-19 19:41:16 +01:00
Natalie Weizenbaum
a46e779675 Clarify !global deprecation warnings
Closes #723
2019-06-18 17:39:29 -07:00
Natalie Weizenbaum
bc4508d80d Remove a reference to Sass 4.0 in a deprecation warning 2019-06-18 17:38:55 -07:00
Natalie Weizenbaum
e4b18b5231
Produce better stack traces for syntax errors loaded via import/use (#722)
We now wrap _withStackFrame() around wider sections of code, including
_loadStylesheet() which handles parse errors, so that the @use/@import
stack frames are available.
2019-06-18 17:26:46 -07:00
Natalie Weizenbaum
d89fef612b Add a module-functions() function 2019-06-18 12:05:56 -07:00
Natalie Weizenbaum
bbaa91d658 Add a module-variables() function 2019-06-18 12:05:26 -07:00
Natalie Weizenbaum
4716349a0e
Add new module-system features for existing functions (#720) 2019-06-18 12:03:12 -07:00
Natalie Weizenbaum
6600de2dfe
Add built-in modules for core Sass functions (#716)
Partially addresses #554
2019-06-12 16:46:28 +01:00
Natalie Weizenbaum
e888f84ce5 Merge branch 'master' into feature.use 2019-06-06 21:46:51 +01:00
Natalie Weizenbaum
bea609d74b
Add a top-level warn() function for functions and importers (#711)
In addition to being useful for users of Sass, this will make it
possible for core Sass functions to produce warnings without needing
an explicit reference to the evaluator.
2019-06-06 19:42:44 +01:00
Natalie Weizenbaum
6494951e48 Improve the error message for module loops 2019-06-04 12:55:43 +01:00
Natalie Weizenbaum
a000bffd98 Add support for @forward
See sass/sass#1094
See #554
2019-06-02 14:26:54 +01:00
Natalie Weizenbaum
11e3749721
Merge pull request #709 from sass/analysis
Enable stricter analysis options, especially around typing
2019-05-31 17:01:13 +01:00
Natalie Weizenbaum
ac38653776 Enable strict raw types 2019-05-31 16:01:49 +01:00
Natalie Weizenbaum
79e9bbd816 Enable strict inference 2019-05-31 15:54:59 +01:00
Natalie Weizenbaum
1340ba7b8a Enable and fix (most) pedantic lints 2019-05-31 15:18:59 +01:00
Natalie Weizenbaum
1ac41898e8 Add map views to represent the ways a module can be forwarded 2019-05-24 16:41:10 -07:00
Natalie Weizenbaum
f6575704dd
Factor out a function to load modules (#693)
This will allow us to re-use logic for @forward. It also fixes some
usability issues where incorrect or duplicated spans were being used
for @use errors.
2019-05-24 16:39:22 -07:00
Natalie Weizenbaum
2836780339
Merge pull request #689 from sass/exponent
Fix some number serialization bugs
2019-05-24 15:09:37 -07:00
Natalie Weizenbaum
6591e315af
Ensure that built-in functions aren't part of a module's API (#692)
The way this worked previously, you could call "mod.rgb()" for any
module and it would be the same as calling the built-in rgb()
function.
2019-05-23 13:24:41 -07:00
Natalie Weizenbaum
0fe0208f6e Remove exponent notation for integers on Node.js
Closes #688
2019-05-21 13:36:36 -07:00
Natalie Weizenbaum
c76ef209af Merge branch 'master' into master-into-use 2019-05-20 16:52:20 -07:00
Natalie Weizenbaum
fb383de20e Fix a bug in SerializeVisitor._writeDecimal
This function didn't expect a number ending in ".0", because they're
normally filtered out by fuzzyAsInt(). However, they can make it
through for very large doubles.
2019-05-20 15:50:45 -07:00
Natalie Weizenbaum
5b9835a5bd Make SerializeVisitor._removeExponent work with non-exponent numbers
This allows us to avoid traversing the number string more times than
necessary.
2019-05-20 15:47:59 -07:00
Natalie Weizenbaum
768da7088c
Resolve imports using custom imports before load paths (#687)
Closes #681
2019-05-20 15:34:57 -07:00
Natalie Weizenbaum
2317be8812
Give Module a type parameter rather than making it synchronized (#686)
This allows us to have one fewer synchronized file, which reduces
complexity, and also lets us just write "Module" in async code rather
than "AsyncModule".
2019-05-20 15:34:14 -07:00
Natalie Weizenbaum
db87ed2f0e
Use the new Dart 2.3.0 literal syntax (#684) 2019-05-17 18:02:12 -07:00
Natalie Weizenbaum
19df69d26c Continue running feature.use in use mode 2019-05-17 14:40:34 -07:00
Natalie Weizenbaum
7c9d63a4dc Reformat with the latest formatter 2019-05-15 18:17:26 -07:00
Natalie Weizenbaum
aaebd424ed Get rid of tool/synchronize.dart
This was moved to tool/grind/synchronize.dart in #318, but the old
file never got removed.
2019-05-15 18:17:06 -07:00
Natalie Weizenbaum
c1ae142ca9 Merge remote-tracking branch 'origin/master' into merge-use 2019-05-15 12:23:42 -07:00
Natalie Weizenbaum
3b47e34c87 Fix some places where a null could sneak into a boolean condition 2019-05-08 17:19:12 -07:00
Natalie Weizenbaum
4b572f6ad5 Merge branch 'feature.use' 2019-05-08 15:38:12 -07:00
Natalie Weizenbaum
92a2c67410 Merge branch 'master' into feature.use 2019-05-06 16:40:24 -07:00
Natalie Weizenbaum
34c068a189
Generate a CSS file describing an error when one occurs (#659)
Closes #657
2019-05-02 18:14:25 -07:00
Natalie Weizenbaum
57260a9fc1
Update color algorithm URLs (#664) 2019-05-02 16:16:33 -07:00
Natalie Weizenbaum
892f301d5a
Remove a debugging print (#655)
This never actually triggered because we always overrode the listener
before the directory was modified.
2019-05-02 13:07:57 -07:00
Natalie Weizenbaum
407eefded1
Add support for attribute selector modifiers (#658)
Closes #656
2019-04-30 11:31:18 -07:00
Natalie Weizenbaum
37f0740307
Allow ! in url()s (#650)
Closes #646
2019-04-18 17:37:20 -07:00
Natalie Weizenbaum
413c949446
Make FilesystemImport._loadPath absolute (#651)
This avoids having the effective load path change when the process's
working directory changes.
2019-04-18 16:34:48 -07:00
Natalie Weizenbaum
3b3a43a8f9
Add a --charset flag and API option (#644)
The automatic @charset adding is useful in general, but there are
consistently cases where it trips up naïve downstream tools. This
option makes it easier for users to control when it occurs.
2019-04-08 14:49:08 -07:00
Natalie Weizenbaum
59800ad1f9
Don't recursively list directories in realCasePath() (#641)
We only need to list the path's immediate parent directory in order to
find its real case.

Closes #636
2019-04-04 12:18:02 -07:00
Natalie Weizenbaum
495c6f3163
Only claim "package:" URLs are unsupported on Node (#637)
Closes #630
2019-04-04 12:17:36 -07:00
Jennifer Thakar
c2c9cedb81 Extend RecursiveStatementVisitor for expressions (#639)
This adds `RecursiveAstVisitor`, which extends
`RecursiveStatementVisitor` to traverse expressions as well.
2019-04-03 14:37:27 -07:00
Natalie Weizenbaum
8c9412b520
Fix importing files relative to "package:" imports (#638)
The PackageImporter wasn't accepting paths relative to its
canonicalized outputs as inputs.

Closes #631
2019-04-03 13:57:52 -07:00
Natalie Weizenbaum
9999835df0
Add a sass.types.Error constructor to the JS API (#627)
Closes #590
2019-04-03 01:07:12 -07:00
Natalie Weizenbaum
eddf36a07e Don't copy the selector in ModifiableStyleRule.copyWithoutChildren() 2019-04-03 01:03:40 -07:00
Natalie Weizenbaum
2d1047bb36 Only clone CSS if it actually uses @extends 2019-03-30 17:47:24 -07:00
Natalie Weizenbaum
d6f319f5b4 Clone CSS after importing it 2019-03-30 17:37:30 -07:00
Natalie Weizenbaum
11c95900c8 Add a Module.cloneCss() function
This will allow us to run extends on the same module multiple times
when it's @imported or loaded via load-file().
2019-03-30 17:05:57 -07:00
Natalie Weizenbaum
eae2077d6b More thoroughly document why we duplicate visitor logic 2019-03-29 16:26:36 -07:00
Natalie Weizenbaum
5603af3d19 Include CSS for modules used by imported files 2019-03-27 14:49:52 -07:00
Natalie Weizenbaum
9f9011d9cc Load @imported CSS into an entirely new stylesheet
This will allow us to inject CSS from modules @used by an imported
stylesheet between the importer's existing CSS and the importee's new
CSS.
2019-03-27 14:49:13 -07:00
Natalie Weizenbaum
511e525619 Add a ModifiableCssVisitor
This lets us traverse a modifiable CSS tree while preserving the fact
that it's modifiable.
2019-03-22 14:09:38 -07:00
Natalie Weizenbaum
14787d86e0 Add "Css" to the visit methods for CssVisitor
This allows the same class to implement StatementVisitor and
CssVisitor.
2019-03-22 13:58:51 -07:00
Natalie Weizenbaum
bc5e3c4f8f
Properly parse CR, CR LF, and FF as newlines everywhere (#626)
Closes #623
2019-03-18 16:50:23 -07:00
Natalie Weizenbaum
cf6801ab5b Fix a typo 2019-03-13 13:30:45 -07:00
Natalie Weizenbaum
f2a34408ec Verify mandatory extensions 2019-03-12 16:53:14 -07:00
Natalie Weizenbaum
0194728f29 Mostly add support for module-scoped @extend
Verifying that a mandatory extension actually matched a real style
rule doesn't work at all.
2019-03-12 16:53:14 -07:00
Natalie Weizenbaum
c80ae01ce0 Make CssStyleRule.originalSelector modifiable-only 2019-03-12 16:53:14 -07:00
Natalie Weizenbaum
132be045f0 Merge branch 'feature.use' into merge-master 2019-03-11 18:36:27 -07:00
Natalie Weizenbaum
c98cfd53b0
Emit CSS for used modules (#620) 2019-03-11 16:49:58 -07:00
Natalie Weizenbaum
e4245a7643 Merge branch 'master' into feature.use 2019-03-10 23:31:06 -07:00
Natalie Weizenbaum
a0e63ac704 Merge branch 'feature.use' into merge-use 2019-03-07 18:17:42 -08:00
Natalie Weizenbaum
b66e1bad28
Fix some documentation issues in AsyncEnvironment (#618)
See #610
2019-03-07 18:14:44 -08:00
Natalie Weizenbaum
62bce0c5b9
Properly stringify slash-separated numbers in operations (#612)
Closes #607
2019-03-07 18:14:12 -08:00
Natalie Weizenbaum
e84c8b1995
Don't put style rules inside empty @keyframes rules (#613)
Closes #611
2019-03-07 17:04:30 -08:00
Natalie Weizenbaum
284f4ef7dd
Make .scss and .sass take precedence over .css in @use (#609)
See sass/language#68
2019-03-04 18:47:57 -08:00
Natalie Weizenbaum
b59b86304d Ensure that global variables are always module members
See sass/language#50
2019-02-22 18:03:24 -08:00
Natalie Weizenbaum
8ab9ce1141
Deprecate assignment to non-existent global variables (#601)
See #600
See sass/sass#2606
2019-02-21 15:16:52 -08:00
Natalie Weizenbaum
6d6974c50e Add the ability to refer to members from other modules 2019-02-21 00:30:04 -08:00
Natalie Weizenbaum
7a7aea95b3 Add a module class and a way to create it from an Environment 2019-02-21 00:30:04 -08:00
Natalie Weizenbaum
5d4db9eb17 Merge branch 'master' into 'feature.use' 2019-02-21 00:29:59 -08:00
Natalie Weizenbaum
149bf85b4d
Explicitly mark classes as sealed (#602) 2019-02-20 16:39:46 -08:00
Natalie Weizenbaum
26401fb135
Fix an attribute selector quoting bug (#599)
Closes #598
2019-02-20 13:38:21 -08:00
Jennifer Thakar
b22ae51955 Fix bug in RecursiveStatementVisitor (#596)
The value of an `AtRule` can be null, so it should not be visited in that case.

Ran across this issue when I attempted to run the module migrator on a stylesheet containing `@font-face` (which has children, but no value).
2019-02-15 13:53:17 -08:00
Natalie Weizenbaum
776e2bfcc2 Disable @use parsing 2019-02-13 00:36:36 -08:00
Natalie Weizenbaum
4b10c22bd4 Add more explanatory error messages 2019-02-13 00:02:42 -08:00
Natalie Weizenbaum
6354cdd02a Don't parse private module member references 2019-02-11 17:17:31 -08:00
Natalie Weizenbaum
d757d99569 Add support for parsing @use 2019-02-11 17:17:31 -08:00
Natalie Weizenbaum
7ca989a4f7
Produce a better error for invalid function contents (#587)
Closes #584
2019-02-04 13:14:25 -08:00
Natalie Weizenbaum
a81017275a
Produce a better error message for unclosed style rules (#586)
Closes #577
2019-02-01 17:21:15 -08:00
Natalie Weizenbaum
b102dc496a
Allow individual directories to be passed on the command-line (#581)
Closes #543
2019-02-01 14:59:58 -08:00
Natalie Weizenbaum
cd3b82e2be
Fix a check for adjusting parse errors (#582) 2019-02-01 14:55:34 -08:00
Natalie Weizenbaum
e8ac314f56
Support dart-lang/source_span#25 (#566)
This adds a --no-unicode option to disable Unicode span rendering,
decouples repl highlighting from SourceSpan.highlight, and updates
tests to work with the new error highlighting.

It also tightly scopes source spans for statements with children.
Previously, source spans for these nodes extended all the way through
any whitespace that followed the node. This led to messy-looking
multiline span highlights with dart-lang/source_span#25.

Now, StylesheetParser.children doesn't consume trailing whitespace.
Instead, we add a helper method StylesheetParser._withChildren that
parses children, creates the appropriate span, and then consumes the
trailing whitespace.
2019-01-28 20:42:32 -05:00
Matt Felten
923615a7f8 Fix "compound selectors may *no* longer be extended" error message (#576) 2019-01-25 20:52:05 -05:00
Natalie Weizenbaum
d3c3a3d515 Delete ModifiableCssNode.modifyChildren
Instead of doing this, we now construct a new (unmodifiable)
CssStylesheet if additional imports need to be added.
2019-01-24 16:25:37 -08:00
Natalie Weizenbaum
93f4876b28 Split the CSS AST into mutable and immutable variants
This codifies in types the constraint that only the evaluator should
modify CSS nodes. It also makes it possible to create non-mutable
classes that don't need to care about stuff like tracking parent nodes.
2019-01-24 15:59:39 -08:00
Natalie Weizenbaum
9fdf5612ea
Fix a performance bug in BinaryOperatorExpression.span (#569)
Previously, evaluator called BinaryOperationExpression.span for each
binary operation it evaluated, which in turn called spanForList() to
create a span covering both child expressions. spanForList() then
called .span for both the left and right child operations *twice*,
leading to exponential behavior.

This is now avoided in three complementary ways:

1. The evaluator avoids eagerly calling AstNode.span, instead keeping
   the original AstNode until the span itself needs to be accessed.
   This means that a span will only be accessed when an error actually
   occurs, and then only one operation's span will be accessed.

2. BinaryOperationExpression.span now iterates through any child
   operations before calling their .span methods, so it only performs
   O(1) allocations.

3. spanForList() now only calls each AstNode.span once.
2019-01-17 18:04:14 -05:00
Natalie Weizenbaum
55ebe56d3c
Add support for new special number strings (#556)
See sass/sass#2584
2019-01-09 15:50:04 -05:00
Natalie Weizenbaum
32be730b6e
Emit tab characters as \9 (#553)
Closes #552
2019-01-04 14:20:28 -05:00
Natalie Weizenbaum
7a75b7b786
Don't canonicalize file case in source maps (#541)
Closes #540
2019-01-04 14:17:18 -05:00
Nicholas Shahan
948fe17a53
Remove unused import (#559)
Originally added in #548 but after changes during review it is no longer needed.
2019-01-03 15:36:05 -08:00
Natalie Weizenbaum
18c0cbdaea
Match Node Sass's this.includePaths behavior for importers (#551)
On Windows, paths are separated with a semicolon rather than a colon.

Closes #549
2019-01-03 10:48:20 -08:00
Natalie Weizenbaum
759b587364
Don't omit units in numbers in compressed mode (#545)
See https://github.com/sass/sass/issues/649#issuecomment-447033060
2019-01-03 10:47:54 -08:00
Natalie Weizenbaum
dbda396401
Compile to JS with -O4 (#555)
Closes #526
2019-01-03 10:47:12 -08:00
Natalie Weizenbaum
06b9fbd812
Merge branch 'master' into windows-path-separator 2018-12-26 14:17:45 -08:00
Natalie Weizenbaum
9f2f11682e
Merge pull request #546 from sass/source-map-urls
Properly use ImportResult.sourceMapUrl for source map URLs
2018-12-20 17:39:28 -08:00
Natalie Weizenbaum
23968148d0 Properly use ImportResult.sourceMapUrl for source map URLs
This also uses data: URLs to refer to stylesheets from stdin in source
maps.
2018-12-20 16:22:43 -08:00
Nicholas Shahan
3a493f23ab
Add documentation comment collection to AST (#548)
- Documentation comments are simply identified by starting with a triple-slash "///". 
- Adjacent comments in indented syntax are now coalesced into a single comment.
2018-12-20 16:08:26 -08:00
Natalie Weizenbaum
9d6de5af23 Add a missing import 2018-12-17 15:52:49 -08:00
Natalie Weizenbaum
519bfa3d6b Match Node Sass's this.includePaths behavior for importers
On Windows, paths are separated with a semicolon rather than a colon.

Closes #549
2018-12-17 15:30:17 -08:00
Natalie Weizenbaum
94fd7e6e50
Match Ruby Sass's number behavior (#544)
This introduces two changes:

1. It changes the epsilon within which two numbers are considered
   equal to be an order of magnitude smaller than the numeric
   precision. Ruby Sass has always done this, and Dart Sass should
   have but did not until now.

2. It parses the component of a number after the decimal point using
   double.parse() to avoid accumulating floating point errors.
2018-12-13 15:27:08 -08:00
Natalie Weizenbaum
fa29e80d29
Merge pull request #542 from sass/compile-refactor
Move some compilation logic from the executable to compile.dart
2018-12-13 11:58:46 -08:00