mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 04:08:41 +08:00
FIX: theme JS should only run when needed global objects exist (#6098)
This commit is contained in:
@ -233,10 +233,12 @@ HTML
|
||||
theme.save!
|
||||
|
||||
transpiled = <<~HTML
|
||||
<script>Discourse._registerPluginCode('1.0', function (api) {
|
||||
var settings = { "name": "bob" };
|
||||
alert(settings.name);var a = function a() {};
|
||||
});</script>
|
||||
<script>if ('Discourse' in window) {
|
||||
Discourse._registerPluginCode('1.0', function (api) {
|
||||
var settings = { "name": "bob" };
|
||||
alert(settings.name);var a = function a() {};
|
||||
});
|
||||
}</script>
|
||||
HTML
|
||||
|
||||
expect(Theme.lookup_field(theme.id, :desktop, :after_header)).to eq(transpiled.strip)
|
||||
@ -245,10 +247,12 @@ HTML
|
||||
setting.value = 'bill'
|
||||
|
||||
transpiled = <<~HTML
|
||||
<script>Discourse._registerPluginCode('1.0', function (api) {
|
||||
var settings = { "name": "bill" };
|
||||
alert(settings.name);var a = function a() {};
|
||||
});</script>
|
||||
<script>if ('Discourse' in window) {
|
||||
Discourse._registerPluginCode('1.0', function (api) {
|
||||
var settings = { "name": "bill" };
|
||||
alert(settings.name);var a = function a() {};
|
||||
});
|
||||
}</script>
|
||||
HTML
|
||||
expect(Theme.lookup_field(theme.id, :desktop, :after_header)).to eq(transpiled.strip)
|
||||
|
||||
|
Reference in New Issue
Block a user