Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Bump LibSass to 3.5.5 #2543

Merged
merged 5 commits into from
Nov 12, 2018
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"object-merge": "^2.5.1",
"read-yaml": "^1.0.0",
"rimraf": "^2.5.2",
"sass-spec": "3.5.4-1",
"sass-spec": "https://github.com/sass/sass-spec.git#dc2d573",
"unique-temp-dir": "^1.0.0"
}
}
3 changes: 1 addition & 2 deletions src/binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
sass_option_set_precision(sass_options, Nan::To<int32_t>(Nan::Get(options, Nan::New("precision").ToLocalChecked()).ToLocalChecked()).FromJust());
sass_option_set_indent(sass_options, ctx_w->indent);
sass_option_set_linefeed(sass_options, ctx_w->linefeed);
sass_option_push_import_extension(sass_options, ".css");

v8::Local<v8::Value> importer_callback = Nan::Get(options, Nan::New("importer").ToLocalChecked()).ToLocalChecked();

Expand Down Expand Up @@ -303,7 +302,7 @@ NAN_METHOD(render_sync) {
}

sass_free_context_wrapper(ctx_w);

info.GetReturnValue().Set(result == 0);
}

Expand Down
3 changes: 0 additions & 3 deletions src/libsass/include/sass/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ ADDAPI size_t ADDCALL sass_compiler_get_callee_stack_size(struct Sass_Compiler*
ADDAPI Sass_Callee_Entry ADDCALL sass_compiler_get_last_callee(struct Sass_Compiler* compiler);
ADDAPI Sass_Callee_Entry ADDCALL sass_compiler_get_callee_entry(struct Sass_Compiler* compiler, size_t idx);

// Push function for import extenions
ADDAPI void ADDCALL sass_option_push_import_extension (struct Sass_Options* options, const char* ext);

// Push function for paths (no manipulation support for now)
ADDAPI void ADDCALL sass_option_push_plugin_path (struct Sass_Options* options, const char* path);
ADDAPI void ADDCALL sass_option_push_include_path (struct Sass_Options* options, const char* path);
Expand Down
4 changes: 2 additions & 2 deletions src/libsass/script/ci-build-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ if [ "x$PLUGIN" == "xglob" ]; then
${SASSC_BIN} --plugin-path plugins/libsass-${PLUGIN}/build ${SASS_SPEC_SPEC_DIR}/basic/input.scss > ${SASS_SPEC_SPEC_DIR}/basic/result.css
${SASSC_BIN} --plugin-path plugins/libsass-${PLUGIN}/build ${SASS_SPEC_SPEC_DIR}/basic/input.scss --sourcemap > /dev/null
else
cat ${SASS_SPEC_SPEC_DIR}/basic/input.scss | ${SASSC_BIN} --plugin-path plugins/libsass-${PLUGIN}/build -I ${SASS_SPEC_SPEC_DIR}/basic > ${SASS_SPEC_SPEC_DIR}/basic/result.css
cat ${SASS_SPEC_SPEC_DIR}/basic/input.scss | ${SASSC_BIN} --plugin-path plugins/libsass-${PLUGIN}/build -I ${SASS_SPEC_SPEC_DIR}/basic --sourcemap > /dev/null
cat ${SASS_SPEC_SPEC_DIR}/basic/input.scss | ${SASSC_BIN} --precision 5 --plugin-path plugins/libsass-${PLUGIN}/build -I ${SASS_SPEC_SPEC_DIR}/basic > ${SASS_SPEC_SPEC_DIR}/basic/result.css
cat ${SASS_SPEC_SPEC_DIR}/basic/input.scss | ${SASSC_BIN} --precision 5 --plugin-path plugins/libsass-${PLUGIN}/build -I ${SASS_SPEC_SPEC_DIR}/basic --sourcemap > /dev/null
fi
RETVAL=$?; if [ "$RETVAL" != "0" ]; then exit $RETVAL; fi

Expand Down
4 changes: 2 additions & 2 deletions src/libsass/src/cencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
*codechar++ = base64_encode_value(result);
result = (fragment & 0x003) << 4;
#ifndef _MSC_VER
__attribute__ ((fallthrough));
/* fall through */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an upstream thing, but it seems odd to have a compiler directive for only a comment now

#endif
case step_B:
if (plainchar == plaintextend)
Expand All @@ -61,7 +61,7 @@ int base64_encode_block(const char* plaintext_in, int length_in, char* code_out,
*codechar++ = base64_encode_value(result);
result = (fragment & 0x00f) << 2;
#ifndef _MSC_VER
__attribute__ ((fallthrough));
/* fall through */
#endif
case step_C:
if (plainchar == plaintextend)
Expand Down
50 changes: 2 additions & 48 deletions src/libsass/src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ namespace Sass {
// include_paths.push_back(CWD);

// collect more paths from different options
collect_extensions(c_options.extension);
collect_extensions(c_options.extensions);
collect_include_paths(c_options.include_path);
collect_include_paths(c_options.include_paths);
collect_plugin_paths(c_options.plugin_path);
Expand Down Expand Up @@ -168,37 +166,6 @@ namespace Sass {
{
}

void Context::collect_extensions(const char* exts_str)
{
if (exts_str) {
const char* beg = exts_str;
const char* end = Prelexer::find_first<PATH_SEP>(beg);

while (end) {
std::string ext(beg, end - beg);
if (!ext.empty()) {
extensions.push_back(ext);
}
beg = end + 1;
end = Prelexer::find_first<PATH_SEP>(beg);
}

std::string ext(beg);
if (!ext.empty()) {
extensions.push_back(ext);
}
}
}

void Context::collect_extensions(string_list* paths_array)
{
while (paths_array)
{
collect_extensions(paths_array->string);
paths_array = paths_array->next;
}
}

void Context::collect_include_paths(const char* paths_str)
{
if (paths_str) {
Expand Down Expand Up @@ -269,20 +236,15 @@ namespace Sass {
// looks for alternatives and returns a list from one directory
std::vector<Include> Context::find_includes(const Importer& import)
{
// include configured extensions
std::vector<std::string> exts(File::defaultExtensions);
if (extensions.size() > 0) {
exts.insert(exts.end(), extensions.begin(), extensions.end());
}
// make sure we resolve against an absolute path
std::string base_path(rel2abs(import.base_path));
// first try to resolve the load path relative to the base path
std::vector<Include> vec(resolve_includes(base_path, import.imp_path, exts));
std::vector<Include> vec(resolve_includes(base_path, import.imp_path));
// then search in every include path (but only if nothing found yet)
for (size_t i = 0, S = include_paths.size(); vec.size() == 0 && i < S; ++i)
{
// call resolve_includes and individual base path and append all results
std::vector<Include> resolved(resolve_includes(include_paths[i], import.imp_path, exts));
std::vector<Include> resolved(resolve_includes(include_paths[i], import.imp_path));
if (resolved.size()) vec.insert(vec.end(), resolved.begin(), resolved.end());
}
// return vector
Expand Down Expand Up @@ -403,14 +365,6 @@ namespace Sass {
// process the resolved entry
else if (resolved.size() == 1) {
bool use_cache = c_importers.size() == 0;
if (resolved[0].deprecated) {
// emit deprecation warning when import resolves to a .css file
deprecated(
"Including .css files with @import is non-standard behaviour which will be removed in future versions of LibSass.",
"Use a custom importer to maintain this behaviour. Check your implementations documentation on how to create a custom importer.",
true, pstate
);
}
// use cache for the resource loading
if (use_cache && sheets.count(resolved[0].abs_path)) return resolved[0];
// try to read the content of the resolved file entry
Expand Down
3 changes: 0 additions & 3 deletions src/libsass/src/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ namespace Sass {

std::vector<std::string> plugin_paths; // relative paths to load plugins
std::vector<std::string> include_paths; // lookup paths for includes
std::vector<std::string> extensions; // lookup extensions for imports`



Expand Down Expand Up @@ -110,8 +109,6 @@ namespace Sass {
void collect_plugin_paths(string_list* paths_array);
void collect_include_paths(const char* paths_str);
void collect_include_paths(string_list* paths_array);
void collect_extensions(const char* extensions_str);
void collect_extensions(string_list* extensions_array);
std::string format_embedded_source_map();
std::string format_source_mapping_url(const std::string& out_path);

Expand Down
4 changes: 2 additions & 2 deletions src/libsass/src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,13 @@ namespace Sass {
for(auto ext : exts) {
rel_path = join_paths(base, "_" + name + ext);
abs_path = join_paths(root, rel_path);
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path, ext == ".css" });
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
}
// next test plain name with exts
for(auto ext : exts) {
rel_path = join_paths(base, name + ext);
abs_path = join_paths(root, rel_path);
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path, ext == ".css" });
if (file_exists(abs_path)) includes.push_back({{ rel_path, root }, abs_path });
}
// nothing found
return includes;
Expand Down
10 changes: 2 additions & 8 deletions src/libsass/src/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,9 @@ namespace Sass {
public:
// resolved absolute path
std::string abs_path;
// is a deprecated file type
bool deprecated;
public:
Include(const Importer& imp, std::string abs_path, bool deprecated)
: Importer(imp), abs_path(abs_path), deprecated(deprecated)
{ }
Include(const Importer& imp, std::string abs_path)
: Importer(imp), abs_path(abs_path), deprecated(false)
: Importer(imp), abs_path(abs_path)
{ }
};

Expand Down Expand Up @@ -126,12 +121,11 @@ namespace Sass {

namespace File {

static std::vector<std::string> defaultExtensions = { ".scss", ".sass" };
static std::vector<std::string> defaultExtensions = { ".scss", ".sass", ".css" };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems off, is this the think where libsass was treating plain CSS as SCSS?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the revert of the CSS import deprecation warning as discussed in #2362


std::vector<Include> resolve_includes(const std::string& root, const std::string& file,
const std::vector<std::string>& exts = defaultExtensions);


}

}
Expand Down
2 changes: 1 addition & 1 deletion src/libsass/src/inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ namespace Sass {
case Complex_Selector::REFERENCE:
append_mandatory_space();
append_string("/");
c->reference()->perform(this);
if (c->reference()) c->reference()->perform(this);
append_string("/");
append_mandatory_space();
break;
Expand Down
31 changes: 29 additions & 2 deletions src/libsass/src/operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ namespace Sass {
bool lte(Expression_Obj lhs, Expression_Obj rhs) { return cmp(lhs, rhs, Sass_OP::LTE) || eq(lhs, rhs); }
bool gte(Expression_Obj lhs, Expression_Obj rhs) { return !cmp(lhs, rhs, Sass_OP::GTE) || eq(lhs, rhs); }

/* colour math deprecation warning */
void op_color_deprecation(enum Sass_OP op, std::string lsh, std::string rhs, const ParserState& pstate)
{
std::string op_str(
op == Sass_OP::ADD ? "plus" :
op == Sass_OP::DIV ? "div" :
op == Sass_OP::SUB ? "minus" :
op == Sass_OP::MUL ? "times" : ""
);

std::string msg("The operation `" + lsh + " " + op_str + " " + rhs + "` is deprecated and will be an error in future versions.");
std::string tail("Consider using Sass's color functions instead.\nhttp://sass-lang.com/documentation/Sass/Script/Functions.html#other_color_functions");

deprecated(msg, tail, false, pstate);
}

/* static function, throws OperationError, has no traces but optional pstate for returned value */
Value_Ptr op_strings(Sass::Operand operand, Value& lhs, Value& rhs, struct Sass_Inspect_Options opt, const ParserState& pstate, bool delayed)
{
Expand Down Expand Up @@ -107,12 +123,16 @@ namespace Sass {
/* static function, throws OperationError, has no traces but optional pstate for returned value */
Value_Ptr op_colors(enum Sass_OP op, const Color& lhs, const Color& rhs, struct Sass_Inspect_Options opt, const ParserState& pstate, bool delayed)
{

if (lhs.a() != rhs.a()) {
throw Exception::AlphaChannelsNotEqual(&lhs, &rhs, op);
}
if (op == Sass_OP::DIV && (!rhs.r() || !rhs.g() || !rhs.b())) {
if ((op == Sass_OP::DIV || op == Sass_OP::MOD) && (!rhs.r() || !rhs.g() || !rhs.b())) {
throw Exception::ZeroDivisionError(lhs, rhs);
}

op_color_deprecation(op, lhs.to_string(), rhs.to_string(), pstate);

return SASS_MEMORY_NEW(Color,
pstate,
ops[op](lhs.r(), rhs.r()),
Expand Down Expand Up @@ -195,9 +215,11 @@ namespace Sass {
Value_Ptr op_number_color(enum Sass_OP op, const Number& lhs, const Color& rhs, struct Sass_Inspect_Options opt, const ParserState& pstate, bool delayed)
{
double lval = lhs.value();

switch (op) {
case Sass_OP::ADD:
case Sass_OP::MUL: {
op_color_deprecation(op, lhs.to_string(), rhs.to_string(opt), pstate);
return SASS_MEMORY_NEW(Color,
pstate,
ops[op](lval, rhs.r()),
Expand All @@ -208,6 +230,7 @@ namespace Sass {
case Sass_OP::SUB:
case Sass_OP::DIV: {
std::string color(rhs.to_string(opt));
op_color_deprecation(op, lhs.to_string(), color, pstate);
return SASS_MEMORY_NEW(String_Quoted,
pstate,
lhs.to_string(opt)
Expand All @@ -223,10 +246,14 @@ namespace Sass {
Value_Ptr op_color_number(enum Sass_OP op, const Color& lhs, const Number& rhs, struct Sass_Inspect_Options opt, const ParserState& pstate, bool delayed)
{
double rval = rhs.value();
if (op == Sass_OP::DIV && rval == 0) {

if ((op == Sass_OP::DIV || op == Sass_OP::DIV) && rval == 0) {
// comparison of Fixnum with Float failed?
throw Exception::ZeroDivisionError(lhs, rhs);
}

op_color_deprecation(op, lhs.to_string(), rhs.to_string(), pstate);

return SASS_MEMORY_NEW(Color,
pstate,
ops[op](lhs.r(), rval),
Expand Down
30 changes: 15 additions & 15 deletions src/libsass/src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1598,6 +1598,19 @@ namespace Sass {
1, // alpha channel
parsed);
}
else if (parsed.length() == 5) {
std::string r(2, parsed[1]);
std::string g(2, parsed[2]);
std::string b(2, parsed[3]);
std::string a(2, parsed[4]);
color = SASS_MEMORY_NEW(Color,
pstate,
static_cast<double>(strtol(r.c_str(), NULL, 16)),
static_cast<double>(strtol(g.c_str(), NULL, 16)),
static_cast<double>(strtol(b.c_str(), NULL, 16)),
static_cast<double>(strtol(a.c_str(), NULL, 16)) / 255,
parsed);
}
else if (parsed.length() == 7) {
std::string r(parsed.substr(1,2));
std::string g(parsed.substr(3,2));
Expand Down Expand Up @@ -1694,17 +1707,7 @@ namespace Sass {
{ return lexed_hex_color(lexed); }

if (lex< hexa >())
{
std::string s = lexed.to_string();

deprecated(
"The value \""+s+"\" is currently parsed as a string, but it will be parsed as a color in",
"future versions of Sass. Use \"unquote('"+s+"')\" to continue parsing it as a string.",
true, pstate
);

return SASS_MEMORY_NEW(String_Quoted, pstate, lexed);
}
{ return lexed_hex_color(lexed); }

if (lex< sequence < exactly <'#'>, identifier > >())
{ return SASS_MEMORY_NEW(String_Quoted, pstate, lexed); }
Expand All @@ -1723,10 +1726,6 @@ namespace Sass {
if (lex< variable >())
{ return SASS_MEMORY_NEW(Variable, pstate, Util::normalize_underscores(lexed)); }

// Special case handling for `%` proceeding an interpolant.
if (lex< sequence< exactly<'%'>, optional< percentage > > >())
{ return SASS_MEMORY_NEW(String_Constant, pstate, lexed); }

css_error("Invalid CSS", " after ", ": expected expression (e.g. 1px, bold), was ");

// unreachable statement
Expand Down Expand Up @@ -2167,6 +2166,7 @@ namespace Sass {
while (pp && peek< exactly< hash_lbrace > >(pp)) {
pp = sequence< interpolant, real_uri_value >(pp);
}
if (!pp) return 0;
position = pp;
return parse_interpolated_chunk(Token(p, position));
}
Expand Down
Loading