Commit Graph

1056 Commits

Author SHA1 Message Date
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