From 53529a3427c8cec6d4c4ed3a4a37864cff4c7396 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Wed, 5 Feb 2020 14:51:00 +0100 Subject: [PATCH] DEV: Upgrade Ember to version 3.12.2 (#8753) * DEV: Use Ember 3.12.2 * Add Ember version to ThemeField's DEPENDENT_CONSTANTS * DEV: Use `id` instead of `elementId` (See: https://github.com/emberjs/ember.js/issues/18147) * FIX: Don't leak event listeners (bug introduced in 999e2ff) --- Gemfile | 2 +- Gemfile.lock | 4 ++-- .../components/topic-timeline.js.es6 | 2 ++ .../javascripts/pretty-text/emoji.js.es6 | 4 ---- .../components/wizard-field-dropdown.hbs | 2 +- .../components/wizard-field-text.hbs | 2 +- .../components/wizard-field-textarea.hbs | 2 +- app/models/theme_field.rb | 7 +++++-- spec/lib/theme_javascript_compiler_spec.rb | 19 +++++++++++-------- 9 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Gemfile b/Gemfile index 1c801d8f3f7..e6df12d56ba 100644 --- a/Gemfile +++ b/Gemfile @@ -65,7 +65,7 @@ gem 'http_accept_language', require: false # Ember related gems need to be pinned cause they control client side # behavior, we will push these versions up when upgrading ember gem 'ember-rails', '0.18.5' -gem 'discourse-ember-source', '~> 3.10.0' +gem 'discourse-ember-source', '~> 3.12.2' gem 'ember-handlebars-template', '0.8.0' gem 'barber' diff --git a/Gemfile.lock b/Gemfile.lock index 95f143b5bee..e5586670fd0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,7 +98,7 @@ GEM debug_inspector (0.0.3) diff-lcs (1.3) diffy (3.3.0) - discourse-ember-source (3.10.0.2) + discourse-ember-source (3.12.2.0) discourse_image_optim (0.26.2) exifr (~> 1.2, >= 1.2.2) fspath (~> 3.0) @@ -455,7 +455,7 @@ DEPENDENCIES cppjieba_rb css_parser diffy - discourse-ember-source (~> 3.10.0) + discourse-ember-source (~> 3.12.2) discourse_image_optim email_reply_trimmer ember-handlebars-template (= 0.8.0) diff --git a/app/assets/javascripts/discourse/components/topic-timeline.js.es6 b/app/assets/javascripts/discourse/components/topic-timeline.js.es6 index b71779e35c9..945524d41c8 100644 --- a/app/assets/javascripts/discourse/components/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-timeline.js.es6 @@ -111,6 +111,8 @@ export default MountWidget.extend(Docking, { }, willDestroyElement() { + this._super(...arguments); + if (!this.site.mobileView) { this.appEvents.off("composer:opened", this, this.queueRerender); this.appEvents.off("composer:resized", this, this.queueRerender); diff --git a/app/assets/javascripts/pretty-text/emoji.js.es6 b/app/assets/javascripts/pretty-text/emoji.js.es6 index fec9b725c4d..12077c01255 100644 --- a/app/assets/javascripts/pretty-text/emoji.js.es6 +++ b/app/assets/javascripts/pretty-text/emoji.js.es6 @@ -126,8 +126,6 @@ export function performEmojiUnescape(string, opts) { } alt='${emojiVal}' class='${classes}'>` : m; }); - - return string; } export function performEmojiEscape(string, opts) { @@ -145,8 +143,6 @@ export function performEmojiEscape(string, opts) { return m; }); - - return string; } export function isCustomEmoji(code, opts) { diff --git a/app/assets/javascripts/wizard/templates/components/wizard-field-dropdown.hbs b/app/assets/javascripts/wizard/templates/components/wizard-field-dropdown.hbs index c2d8f495aa7..e311b0183e9 100644 --- a/app/assets/javascripts/wizard/templates/components/wizard-field-dropdown.hbs +++ b/app/assets/javascripts/wizard/templates/components/wizard-field-dropdown.hbs @@ -1,5 +1,5 @@ {{combo-box - elementId=field.id + id=field.id class=fieldClass value=field.value content=field.choices diff --git a/app/assets/javascripts/wizard/templates/components/wizard-field-text.hbs b/app/assets/javascripts/wizard/templates/components/wizard-field-text.hbs index 7e53f27dc23..77d7602575d 100644 --- a/app/assets/javascripts/wizard/templates/components/wizard-field-text.hbs +++ b/app/assets/javascripts/wizard/templates/components/wizard-field-text.hbs @@ -1 +1 @@ -{{input elementId=field.id value=field.value class=fieldClass placeholder=field.placeholder tabindex="9"}} +{{input id=field.id value=field.value class=fieldClass placeholder=field.placeholder tabindex="9"}} diff --git a/app/assets/javascripts/wizard/templates/components/wizard-field-textarea.hbs b/app/assets/javascripts/wizard/templates/components/wizard-field-textarea.hbs index 14707f3a87a..063db210e4a 100644 --- a/app/assets/javascripts/wizard/templates/components/wizard-field-textarea.hbs +++ b/app/assets/javascripts/wizard/templates/components/wizard-field-textarea.hbs @@ -1 +1 @@ -{{textarea elementId=field.id value=field.value class=fieldClass placeholder=field.placeholder tabindex="9"}} +{{textarea id=field.id value=field.value class=fieldClass placeholder=field.placeholder tabindex="9"}} diff --git a/app/models/theme_field.rb b/app/models/theme_field.rb index fe4e0bf644f..218c880c0fd 100644 --- a/app/models/theme_field.rb +++ b/app/models/theme_field.rb @@ -61,8 +61,11 @@ class ThemeField < ActiveRecord::Base if: Proc.new { |field| ThemeField.theme_var_type_ids.include?(field.type_id) } BASE_COMPILER_VERSION = 14 - DEPENDENT_CONSTANTS = [BASE_COMPILER_VERSION, - GlobalSetting.cdn_url] + DEPENDENT_CONSTANTS = [ + BASE_COMPILER_VERSION, + Ember::VERSION, + GlobalSetting.cdn_url + ] COMPILER_VERSION = Digest::SHA1.hexdigest(DEPENDENT_CONSTANTS.join) belongs_to :theme diff --git a/spec/lib/theme_javascript_compiler_spec.rb b/spec/lib/theme_javascript_compiler_spec.rb index cf80db014de..911ce18c098 100644 --- a/spec/lib/theme_javascript_compiler_spec.rb +++ b/spec/lib/theme_javascript_compiler_spec.rb @@ -74,6 +74,11 @@ describe ThemeJavascriptCompiler do # For the Ember (Glimmer) templates, serverside rendering is not trivial, # so check the compiled JSON against known working output let(:compiler) { described_class.new(theme_id) } + let(:helper_opcode) do + append = statement("{{dummy-helper 1}}")[0] + helper = append[1] + helper[0] + end def statement(template) compiled = compiler.compile(template) @@ -82,28 +87,26 @@ describe ThemeJavascriptCompiler do block["statements"] end - # might change/break when updating ember - EMBER_INTERNAL_ID = 29 it 'adds the theme id to the helpers' do expect(statement("{{theme-prefix 'translation_key'}}")). - to eq([[1, [EMBER_INTERNAL_ID, "theme-prefix", [22, "translation_key"], nil], false]]) + to eq([[1, [helper_opcode, "theme-prefix", [22, "translation_key"], nil], false]]) expect(statement("{{theme-i18n 'translation_key'}}")). - to eq([[1, [EMBER_INTERNAL_ID, "theme-i18n", [22, "translation_key"], nil], false]]) + to eq([[1, [helper_opcode, "theme-i18n", [22, "translation_key"], nil], false]]) expect(statement("{{theme-setting 'setting_key'}}")). - to eq([[1, [EMBER_INTERNAL_ID, "theme-setting", [22, "setting_key"], nil], false]]) + to eq([[1, [helper_opcode, "theme-setting", [22, "setting_key"], nil], false]]) # Works when used inside other statements expect(statement("{{dummy-helper (theme-prefix 'translation_key')}}")). - to eq([[1, [EMBER_INTERNAL_ID, "dummy-helper", [[EMBER_INTERNAL_ID, "theme-prefix", [22, "translation_key"], nil]], nil], false]]) + to eq([[1, [helper_opcode, "dummy-helper", [[helper_opcode, "theme-prefix", [22, "translation_key"], nil]], nil], false]]) end it 'works with the old settings syntax' do expect(statement("{{themeSettings.setting_key}}")). - to eq([[1, [EMBER_INTERNAL_ID, "theme-setting", [22, "setting_key"], [["deprecated"], [true]]], false]]) + to eq([[1, [helper_opcode, "theme-setting", [22, "setting_key"], [["deprecated"], [true]]], false]]) # Works when used inside other statements expect(statement("{{dummy-helper themeSettings.setting_key}}")). - to eq([[1, [EMBER_INTERNAL_ID, "dummy-helper", [[EMBER_INTERNAL_ID, "theme-setting", [22, "setting_key"], [["deprecated"], [true]]]], nil], false]]) + to eq([[1, [helper_opcode, "dummy-helper", [[helper_opcode, "theme-setting", [22, "setting_key"], [["deprecated"], [true]]]], nil], false]]) end end