Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump sass from 1.66.1 to 1.67.0 in /ext/sass #153

Merged
merged 4 commits into from
Sep 14, 2023
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 ext/sass/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dependencies": {
"sass": "1.66.1"
"sass": "1.67.0"
}
}
12 changes: 5 additions & 7 deletions lib/sass/embedded/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,11 @@ def version_response(message)
end

def error(message)
if message.is_a?(EmbeddedProtocol::ProtocolError)
return if message.id != id

@error = Errno::EPROTO.new(message.message)
else
@error = message
end
@error = if message.is_a?(EmbeddedProtocol::ProtocolError)
Errno::EPROTO.new(message.message)
else
message
end
@queue.close
end

Expand Down
1 change: 0 additions & 1 deletion spec/sass/value/calculation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@
Sass.compile_string('a {b: foo()}',
functions: { 'foo()': fn }).css
end.to raise_error do |error|
expect(error).to be_a(Sass::CompileError)
expect(error.full_message).to match(/"foo" is not a recognized calculation type/)
end
end
Expand Down
180 changes: 155 additions & 25 deletions spec/sass_importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,31 +226,6 @@
end
end

it 'prefers a relative importer load to an importer' do
result = described_class.compile_string(
'@import "other";',
importers: [{
canonicalize: lambda { |*|
raise 'canonicalize() should not be called'
},
load: lambda { |*|
raise 'load() should not be called'
}
}],
url: 'o:style.scss',
importer: {
canonicalize: ->(url, **) { url },
load: lambda { |*|
return {
contents: 'a {from: relative}',
syntax: 'scss'
}
}
}
)
expect(result.css).to eq("a {\n from: relative;\n}")
end

it 'prefers an importer to a load path' do
sandbox do |dir|
dir.write({
Expand Down Expand Up @@ -337,6 +312,161 @@
end
end

describe "compile_string()'s importer option" do
it 'loads relative imports from the entrypoint' do
result = described_class.compile_string(
'@import "orange";',
importer: {
canonicalize: lambda { |url, **|
expect(url).to eq('u:orange')
url
},
load: lambda { |url|
color = url.split(':')[1]
return {
contents: ".#{color} {color: #{color}}",
syntax: 'scss'
}
}
},
url: 'u:entrypoint'
)

expect(result.css).to eq(".orange {\n color: orange;\n}")
end

it 'takes precedence over the importer list for relative URLs' do
result = described_class.compile_string(
'@import "other";',
importer: {
canonicalize: lambda { |url, **|
url
},
load: lambda { |_url|
return {
contents: 'a {from: relative}',
syntax: 'scss'
}
}
},
importers: [{
canonicalize: lambda { |*|
raise 'canonicalize() should not be called'
},
load: lambda { |*|
raise 'load() should not be called'
}
}],
url: 'o:style.scss'
)

expect(result.css).to eq("a {\n from: relative;\n}")
end

it "doesn't load absolute imports" do
result = described_class.compile_string(
'@import "u:orange";',
importer: {
canonicalize: lambda { |*|
raise 'canonicalize() should not be called'
},
load: lambda { |*|
raise 'load() should not be called'
}
},
importers: [{
canonicalize: lambda { |url, **|
expect(url).to eq('u:orange')
url
},
load: lambda { |url|
color = url.split(':')[1]
return {
contents: ".#{color} {color: #{color}}",
syntax: 'scss'
}
}
}],
url: 'x:entrypoint'
)

expect(result.css).to eq(".orange {\n color: orange;\n}")
end

it "doesn't load from other importers" do
result = described_class.compile_string(
'@import "u:midstream";',
importer: {
canonicalize: lambda { |*|
raise 'canonicalize() should not be called'
},
load: lambda { |*|
raise 'load() should not be called'
}
},
importers: [{
canonicalize: lambda { |url, **|
url
},
load: lambda { |url|
pathname = url.split(':')[1]
if pathname == 'midstream'
return {
contents: "@import 'orange';",
syntax: 'scss'
}
else
color = pathname
return {
contents: ".#{color} {color: #{color}}",
syntax: 'scss'
}
end
}
}],
url: 'x:entrypoint'
)

expect(result.css).to eq(".orange {\n color: orange;\n}")
end

it 'importer order is preserved for absolute imports' do
# The second importer should only be invoked once, because when the
# "first:other" import is resolved it should be passed to the first
# importer first despite being in the second importer's file.
second_called = false
result = described_class.compile_string(
'@import "second:other";',
importers: [{
canonicalize: lambda { |url, **|
url if url.start_with?('first:')
},
load: lambda { |*|
return {
contents: 'a {from: first}',
syntax: 'scss'
}
}
}, {
canonicalize: lambda { |url, **|
raise 'Second importer should only be called once.' if second_called

second_called = true
url if url.start_with?('second:')
},
load: lambda { |*|
return {
contents: '@import "first:other";',
syntax: 'scss'
}
}
}]
)

expect(result.css).to eq("a {\n from: first;\n}")
end
end

describe 'from_import is' do
def expect_from_import(canonicalize, expected)
allow(canonicalize).to receive(:call) { |url, from_import:|
Expand Down
6 changes: 4 additions & 2 deletions spec/sass_proto_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ def remote_eq(lhs, rhs)
__LINE__ => Sass::Value::Calculation.max([
Sass::Value::String.new('1', quoted: false),
Sass::Value::Number.new(42, 'px'),
Sass::CalculationValue::CalculationInterpolation.new('1em')
Sass::Value::Calculation.min([
Sass::Value::Number.new(1, 'rem'),
Sass::Value::Number.new(42, 'pt')
])
]),
__LINE__ => Sass::Value::Calculation.clamp(Sass::CalculationValue::CalculationInterpolation.new('var(--clamp)')),
__LINE__ => Sass::Value::Calculation.clamp(Sass::Value::String.new('var(--clamp)', quoted: false)),
__LINE__ => Sass::Value::Color.new(red: 0, green: 0, blue: 0, alpha: 1),
__LINE__ => Sass::Value::Color.new(hue: 0, saturation: 0, lightness: 0, alpha: 1),
Expand Down