Skip to content

Commit

Permalink
Deprecate #RRGGBBAA and #RGBA id parsing. (#2226)
Browse files Browse the repository at this point in the history
See #2179
  • Loading branch information
nex3 committed Jan 14, 2017
1 parent 719163a commit 72ad83e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 10 additions & 0 deletions doc-src/SASS_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@
this is likely to result in a situation where the framework cannot
resolve the function in 4.0.

* Values that can be interpreted as
[hex colors with alpha channels][hex alpha spec] and also as
[ID values][directional focus spec], such as `#abcd`, now emit deprecation
warnings in preparation for being parsed differently Sass 3.6. They were
previously parsed as strings, and in 3.6 they will be parsed as colors
instead.

[hex alpha spec]: https://drafts.csswg.org/css-color/#hex-notation
[directional focus spec]: https://www.w3.org/TR/css-ui-3/#nav-dir

### Backwards Incompatibilities -- Must Read!

* The way [CSS variables][] are handled has changed to better correspond to the
Expand Down
13 changes: 11 additions & 2 deletions lib/sass/script/lexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,17 @@ def id
# IDs in properties are used in the Basic User Interface Module
# (http://www.w3.org/TR/css3-ui/).
return unless scan(REGULAR_EXPRESSIONS[:id])
if @scanner[0] =~ /^\#[0-9a-fA-F]+$/ && (@scanner[0].length == 4 || @scanner[0].length == 7)
return [:color, Script::Value::Color.from_hex(@scanner[0])]
if @scanner[0] =~ /^\#[0-9a-fA-F]+$/
if @scanner[0].length == 4 || @scanner[0].length == 7
return [:color, Script::Value::Color.from_hex(@scanner[0])]
elsif @scanner[0].length == 5 || @scanner[0].length == 9
filename = @options[:filename]
Sass::Util.sass_warn <<MESSAGE
DEPRECATION WARNING on line #{line}, column #{offset}#{" of #{filename}" if filename}:
The value "#{@scanner[0]}" is currently parsed as a string, but it will be parsed as a color in
future versions of Sass. Use "unquote('#{@scanner[0]}')" to continue parsing it as a string.
MESSAGE
end
end
[:ident, @scanner[0]]
end
Expand Down

0 comments on commit 72ad83e

Please sign in to comment.