mirror of
https://github.com/discourse/discourse.git
synced 2025-04-09 05:20:49 +08:00
FIX: Do not output empty style tags for components (#12229)
This commit is contained in:
parent
3b7c2328fb
commit
cf0192018e
@ -615,6 +615,11 @@ class Theme < ActiveRecord::Base
|
|||||||
contents
|
contents
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_scss(target)
|
||||||
|
name = target == :embedded_theme ? :embedded_scss : :scss
|
||||||
|
list_baked_fields(target, name).count > 0
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def to_scss_variable(name, value)
|
def to_scss_variable(name, value)
|
||||||
|
@ -83,6 +83,7 @@ class Stylesheet::Manager
|
|||||||
if is_theme && !has_theme
|
if is_theme && !has_theme
|
||||||
next
|
next
|
||||||
else
|
else
|
||||||
|
next if builder.theme&.component && !builder.theme&.has_scss(target)
|
||||||
data[:theme_id] = builder.theme.id if has_theme && is_theme
|
data[:theme_id] = builder.theme.id if has_theme && is_theme
|
||||||
builder.compile unless File.exists?(builder.stylesheet_fullpath)
|
builder.compile unless File.exists?(builder.stylesheet_fullpath)
|
||||||
href = builder.stylesheet_path(current_hostname)
|
href = builder.stylesheet_path(current_hostname)
|
||||||
|
@ -105,7 +105,21 @@ describe Stylesheet::Manager do
|
|||||||
expect(hrefs[1][:theme_id]).to eq(child_theme.id)
|
expect(hrefs[1][:theme_id]).to eq(child_theme.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not output multiple assets for non-themes' do
|
it 'does not output tags for component targets with no styles' do
|
||||||
|
embedded_scss_child = Fabricate(:theme, component: true)
|
||||||
|
embedded_scss_child.set_field(target: :common, name: "embedded_scss", value: ".scss{color: red;}")
|
||||||
|
embedded_scss_child.save!
|
||||||
|
|
||||||
|
theme.add_relative_theme!(:child, embedded_scss_child)
|
||||||
|
|
||||||
|
hrefs = Stylesheet::Manager.stylesheet_details(:desktop_theme, 'all', [theme.id])
|
||||||
|
expect(hrefs.count).to eq(2) # theme + child_theme
|
||||||
|
|
||||||
|
hrefs = Stylesheet::Manager.stylesheet_details(:embedded_theme, 'all', [theme.id])
|
||||||
|
expect(hrefs.count).to eq(3) # theme + child_theme + embedded_scss_child
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not output multiple assets for non-theme targets' do
|
||||||
hrefs = Stylesheet::Manager.stylesheet_details(:admin, 'all', [theme.id])
|
hrefs = Stylesheet::Manager.stylesheet_details(:admin, 'all', [theme.id])
|
||||||
expect(hrefs.count).to eq(1)
|
expect(hrefs.count).to eq(1)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user